首页 > 解决方案 > Flutter:将图标对齐到中间——底部导航栏

问题描述

我的颤振应用程序中有一个底部导航栏。如何将图标对齐到中间。目前,它似乎是顶部对齐

Widget _bottomNavigationBar(int selectedIndex) {
    return BottomNavigationBar(
      backgroundColor: Palette.YELLOW,
      onTap: (int index) {
        setState(() {
          userModel.selectedIndex = index;
        });
      },
      currentIndex: userModel.selectedIndex,
      items: <BottomNavigationBarItem>[
        BottomNavigationBarItem(
          icon: Image.asset(
            "assets/images/search_nav_icon.png",

          ),
          title: Text(''),
        ),
        BottomNavigationBarItem(
            icon: Image.asset(
              "assets/images/fav_nav_icon.png",

            ),
      ],
    );
  }

在此处输入图像描述

标签: flutter

解决方案


当使用图标且没有文本时,这对我有用。

return BottomNavigationBar( showSelectedLabels: false, showUnselectedLabel: false, // ... );


推荐阅读