dart – Flutter BottomNavigationBar不能使用超过三个项目

dart – Flutter BottomNavigationBar不能使用超过三个项目,第1张

概述我在Flutter(0.6)中的BottomNavigationBar有问题.一旦我添加了超过三个BottomNavigationBarItems作为子项,栏中的按钮就会出现白色图标并且它们会混乱.当我只使用三件或更少的物品时,一切都很好. 这是我使用的小部件代码,它打破了这个障碍: bottomNavigationBar: BottomNavigationBar( curre 我在Flutter(0.6)中的BottomNavigationbar有问题.一旦我添加了超过三个BottomNavigationbarItems作为子项,栏中的按钮就会出现白色图标并且它们会混乱.当我只使用三件或更少的物品时,一切都很好.

这是我使用的小部件代码,它打破了这个障碍:

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))        ])

有没有人知道这里有什么问题?

提前感谢任何提示,
迈克尔

解决方法 从 https://github.com/flutter/flutter/issues/13642#issuecomment-371875044起

When more than 3 BottomNavigationbar items are provIDed the type,if
unspecifIEd,changes to BottomNavigationbarType.shifting per
07001.
This bit of information should be highlighted in the class’s doc. It’s
easy to overlook where it is (I overlooked it).

When the BottomNavigationbar’s type is
BottomNavigationbarType.shifting the items text and icons are
rendered in white,via DefaultTextStyle and Icontheme. It’s assumed
that theirBottomNavigationbarItem.backgroundcolor will be specifIEd
as a contrasting color. This is obvIoUsly confusing.

The overall IDea with shifting type bottom navigation bars is that
each item will have a different background color (that contrasts with
white),since that color will become the color of the entire
navigation bar,when the item is selected.

The doc for BottomNavigationbar,and NavigationbarItem needs to be improved.

总结

以上是内存溢出为你收集整理的dart – Flutter BottomNavigationBar不能使用超过三个项目全部内容,希望文章能够帮你解决dart – Flutter BottomNavigationBar不能使用超过三个项目所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1001916.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存