【问题标题】:The space between the items in the Bottom Navigation Bar底部导航栏中项目之间的空间
【发布时间】:2022-11-23 18:34:45
【问题描述】:
  bottomNavigationBar: BottomNavigationBar(
    showSelectedLabels: false,
    showUnselectedLabels: false,
    items: const <BottomNavigationBarItem>[
      BottomNavigationBarItem(
        icon: FaIcon(
          FontAwesomeIcons.solidCompass,
          color: darkblue,
        ),
        label: 'Home',
      ),
      BottomNavigationBarItem(
        icon: FaIcon(
          FontAwesomeIcons.route,
          color: darkblue,
        ),
        label: 'Routes',
      ),
      BottomNavigationBarItem(
        icon: FaIcon(
          FontAwesomeIcons.circlePlus,
          color: darkblue,
        ),
        label: 'Add',
      ),
      BottomNavigationBarItem(
        icon: FaIcon(
          FontAwesomeIcons.solidMessage,
          color: darkblue,
        ),
        label: 'Chat',
      ),
    ],

我创建了这样一个 BottomNavigationBar 并向其中添加了项目,但第一个项目看起来与其他项目非常不同。如何使所有项目之间的间距相同?

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    您需要设置“类型:BottomNavigationBarType.fixed”以在所有项目上设置相同的宽度。您看到的空间位于选定的索引上。

    像这样:

    BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        ...
    )
    

    【讨论】: