Joe*_*röm 3 flutter bottomnavigationview flutter-layout
我只需要底部导航栏项中的标签,但我找不到删除它们的方法。
您可以使用showSelectedLabels和showUnselectedLabels设置为 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,
})
Run Code Online (Sandbox Code Playgroud)
这个问题的关键是看个人BottomNavigationBarItem()。
如果您插入一个高度为 0.0 的 Container 作为标题,您将获得图标或 activeIcon 项目的所有垂直空间。而且由于BottomNavigationBarItem接受任何小部件作为 icon 或 activeIcon 你几乎可以随意使用任何你想要的。
在你的情况下可能只是一个Text()像这样的小部件:
BottomNavigationBarItem(
icon: Text("My Item"),
activeIcon: Text("My Item"),
title: Container(
height: 0.0,
),
)
Run Code Online (Sandbox Code Playgroud)
我认为更好的方法是配置 BottomNavigationBar。只需添加这一行即可正常工作。无需为每个项目添加行
selectedIconTheme: IconThemeData(opacity: 0.0, size: 0),
unselectedIconTheme: IconThemeData(opacity: 0.0, size: 0),
Run Code Online (Sandbox Code Playgroud)
前任。
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
label: 'Business',
),
],
currentIndex: _selectedIndex,
selectedIconTheme: IconThemeData(opacity: 0.0, size: 0),
unselectedIconTheme: IconThemeData(opacity: 0.0, size: 0),
selectedItemColor: Colors.amber[800],
onTap: _onItemTapped,
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
981 次 |
| 最近记录: |