如何从BottomNavigationBar删除图标?

问题描述 投票:0回答:1

我只需要BottomNavigationBarItem中的标签,但是我找不到删除它们的方法。您可以通过将showSelectedLabelsshowUnselectedLabels设置为false来隐藏标签,但是图标没有等效的标签。

构造函数:

BottomNavigationBar({
    Key key,
    @required this.items,
    this.onTap,
    this.currentIndex = 0,
    this.elevation = 8.0,
    BottomNavigationBarType type,
    Color fixedColor,
    this.backgroundColor,
    this.iconSize = 24.0,
    Color selectedItemColor,
    this.unselectedItemColor,
    this.selectedIconTheme = const IconThemeData(),
    this.unselectedIconTheme = const IconThemeData(),
    this.selectedFontSize = 14.0,
    this.unselectedFontSize = 12.0,
    this.selectedLabelStyle,
    this.unselectedLabelStyle,
    this.showSelectedLabels = true,
    bool showUnselectedLabels,
  })
flutter flutter-layout bottomnavigationview
1个回答
1
投票

此问题的关键是查看单个的BottomNavigationBarItem()

如果您插入一个高度为0.0的容器作为标题,则将获得该图标或activeIcon项目的所有垂直空间。而且由于BottomNavigationBarItem接受any widget作为图标或activeIcon,因此您几乎可以随意使用任何所需的内容。

在您的情况下,可能只是这样的Text()小部件:

BottomNavigationBarItem(
  icon: Text("My Item"),
  activeIcon: Text("My Item"),
  title: Container(
    height: 0.0,
  ),
)
© www.soinside.com 2019 - 2024. All rights reserved.