小编ell*_*311的帖子

如何从 flutter 中的底部导航栏中删除标签,以便可以水平居中添加按钮?

有人可以帮我解决这个问题吗?我目前找到的唯一解决方案是将 showSelectedLabels 和 showUnselecedLabels 设置为 false。但是,这将删除所有标签,但我只想删除添加按钮的标签。如果我只使用占位符“”作为标签,我的添加按钮就会水平偏离中心......

按钮关闭水平居中

我想要的结果

Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: tabs[_selectedIndex],
      ),
      bottomNavigationBar: BottomNavigationBar(
        elevation: 10,
        backgroundColor: Colors.white,
        type: BottomNavigationBarType.fixed,
        selectedIconTheme: IconThemeData(color: kPrimaryMagentaColor),
        selectedLabelStyle: TextStyle(fontWeight: FontWeight.w500),
        selectedItemColor: Colors.black,
        showSelectedLabels: true,
        showUnselectedLabels: true,
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Container(
              padding: kBottomNavIconLabelSpace,
              child: Icon(
                FeatherIcons.map,
                size: 26.5,
              ),
            ),
            label: 'Map',
          ),
          BottomNavigationBarItem(
            icon: Container(
              padding: kBottomNavIconLabelSpace,
              child: Icon(
                FeatherIcons.compass,
                size: 28,
              ),
            ),
            label: 'Discover',
          ),
          BottomNavigationBarItem(
            icon: Container(
              decoration: BoxDecoration(
                color: kPrimaryMagentaColor,
                shape: BoxShape.circle, …
Run Code Online (Sandbox Code Playgroud)

navigationbar flutter flutter-bottomnavigation

5
推荐指数
2
解决办法
1万
查看次数