Dart 颤振底部导航栏不能处理三个以上的项目
我对颤振(0.6)中的底部导航条有问题。当我将添加到三个以上的BottomNavigationBarItems作为孩子时,栏中的按钮就会出现白色图标,并且它们被弄乱了。当我只使用三件或更少的物品时,一切都很好 以下是我使用的小部件代码,它打破了标准:Dart 颤振底部导航栏不能处理三个以上的项目,dart,flutter,Dart,Flutter,我对颤振(0.6)中的底部导航条有问题。当我将添加到三个以上的BottomNavigationBarItems作为孩子时,栏中的按钮就会出现白色图标,并且它们被弄乱了。当我只使用三件或更少的物品时,一切都很好 以下是我使用的小部件代码,它打破了标准: bottomNavigationBar: BottomNavigationBar( currentIndex: 0, iconSize: 20.0, items: [
bottomNavigationBar: BottomNavigationBar(
currentIndex: 0,
iconSize: 20.0,
items: [
BottomNavigationBarItem(
title: Text('Home'), icon: Icon(Icons.accessibility)),
BottomNavigationBarItem(
title: Text('Preise'), icon: Icon(Icons.account_box)),
BottomNavigationBarItem(
title: Text('Test'), icon: Icon(Icons.adb)),
BottomNavigationBarItem(
title: Text('Mehr'), icon: Icon(Icons.menu))
])
有人知道这里出了什么问题吗
提前感谢您的任何提示,
Michael对于4个或更多项目,请将
类型设置为固定
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed, // This is all you need!
items: // ...,
)
从
如果提供了3个以上的BottomNavigationBar项,则类型为
未指定,更改为BottomNavigationBarType.Shift
per
.
这个信息应该在类的文档中突出显示。它是
容易忽略它的位置(我忽略了它)
当BottomNavigationBar的类型为
BottomNavigationBarType.shift
项目文本和图标为
通过DefaultTextStyle和IconTheme以白色呈现。这是假定的
将指定他们的BottomNavigationBarItem.backgroundColor
作为对比色。这显然令人困惑
移动
类型底部导航栏的总体思路是
每个项目都有不同的背景色(与
白色),因为该颜色将成为整个系统的颜色
选择项目时的导航栏
需要创建BottomNavigationBar和NavigationBarItem的文档
改善了
添加类型:BottomNavigationBarType。已修复BottomNavigationBar上的
bottomNavigationBar: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('A')),
BottomNavigationBarItem(icon: Icon(Icons.access_alarm), title: Text('B')),
BottomNavigationBarItem(icon: Icon(Icons.business), title: Text('C')),
BottomNavigationBarItem(icon: Icon(Icons.school), title: Text('D')),
],
bottomNavigationBar:bottomNavigationBar(
类型:BottomNavigationBarType.fixed,
项目:[
BottomNavigationBarItem(图标:icon(Icons.home),标题:Text('A')),
BottomNavigationBarItem(图标:图标(Icons.access_报警),标题:文本('B')),
BottomNavigationBarItem(图标:icon(Icons.business),标题:Text('C'),
BottomNavigationBarItem(图标:icon(Icons.school),标题:Text('D'),
],
设置“showUnselectedLabels:true”将恢复BottomNavigationBar的行为。切换为BottomNavigationBar.fixed的默认行为。基本上,您可能需要执行的操作。