flutter - Flutter 调整浮动操作按钮的底部标签间距
问题描述
我正在尝试调整选项卡的间距,以使其在停靠在底部中心的浮动操作按钮附近看起来不尴尬。我正在考虑添加一个“不可见”图标,但这意味着用户可能会错误地点击它,我认为这不是最好的解决方法。
我的小部件:
Widget build(context) {
return new Scaffold(
body: TabBarView(
children: _displayTabPages(),
),
bottomNavigationBar: BottomAppBar(
child: _createTabBar(),
color: Colors.blue,
shape: CircularNotchedRectangle(),
notchMargin: 5.0,
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
floatingActionButton: FloatingActionButton(
onPressed: () {},
tooltip: 'Add Transaction',
backgroundColor: Colors.orange[300],
foregroundColor: Colors.black87,
child: Icon(FontAwesomeIcons.plus),
elevation: 2.0,
),
);
}
我的标签栏:
Widget _createTabBar() {
return TabBar(
tabs: [
Tab(
icon: new Icon(FontAwesomeIcons.list),
),
Tab(
icon: new Icon(FontAwesomeIcons.calendarAlt),
),
Tab(
icon: new Icon(FontAwesomeIcons.chartPie),
),
Tab(
icon: new Icon(FontAwesomeIcons.cog),
)
],
labelColor: Colors.white,
unselectedLabelColor: Colors.black87,
indicatorColor: Colors.blue,
);
}
以上创建了这个:
有没有办法修复中间图标之间的间距?
解决方案
您可以通过添加 centerItemText 来参考以下两个链接来解决您的问题。您也可以使用空白空间而不是文本。
https://medium.com/coding-with-flutter/flutter-bottomappbar-navigation-with-fab-8b962bb55013
https://github.com/bizz84/bottom_bar_fab_flutter/blob/master/lib/fab_bottom_app_bar.dart
推荐阅读
- visual-studio - Visual Studio 使用多个不同的程序集、产品和文件名编译同一个项目
- node.js - 将十六进制数据保存到 NodeJS 中的文件
- python-3.x - python 3.x insert 函数在使用负一进行索引时的行为与其他列表函数不同,这是有原因的吗?
- php - 如何确定给定的邮政编码是否介于 (K2T - K4P) 之间
- websphere - Websphere Console 9.0 - 在 websphere 控制台中指定应用程序特定文件路径的位置
- excel - 如何在 Excel 中为矩阵创建公式
- momentjs - momentjs 添加一周返回错误的 res
- ethereum - 错误:调用还原异常(使用 dydx、Uniswap 和 Kyber 进行闪贷)
- vue.js - Vue模板中是否可以有动态元素名称?
- html - 修改引导复选框样式