Flutter布局基础——自定义BottomNavigationBar
背景
这里我们来尝试实现一个不规则的 BottomNavigationBar,首先了解两个系统组件: floatingActionButton
和BottomAppBar
floatingActionButton
floatingActionButton
用于创建一个浮动的按钮,有两种样式:一种是圆形的纯图标的;一种是椭圆的带有图标或文案的。
示例如下:
1 |
|
显示效果:

1 |
|
显示效果:

BottomAppBar
要实现的效果如下:

下面来分析如何实现:
body 是 ListView,ListView 的内容从上到下是:
- 两个
SwitchListTile
- 一个
Padding
- 四个
RadioListTile
再然后是 floatingActionButton
再然后是 BottomAppBar
如下:

代码如下:
1 |
|
要注意floatingActionButtonLocation
的设置