【问题标题】:Flutter Adjust bottom tab spacing for floating action buttonFlutter 调整浮动操作按钮的底部标签间距
【发布时间】:2019-09-07 18:48:17
【问题描述】:

我正在尝试调整选项卡的间距,以使其在停靠在底部中心的浮动操作按钮附近看起来不会很尴尬。我正在考虑添加一个“不可见”图标,但这意味着用户可能会错误地点击它,我认为这不是最好的解决方法。

我的小部件:

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,
  );
}

上面创建了这个:

有没有办法固定中间图标之间的间距?

【问题讨论】:

    标签: flutter


    【解决方案1】:

    您可以通过添加 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

    【讨论】:

      猜你喜欢
      • 2022-10-05
      • 2015-08-26
      • 1970-01-01
      • 2016-11-22
      • 2016-06-24
      • 2019-02-09
      • 2018-08-21
      • 2020-03-25
      相关资源
      最近更新 更多