gpt4 book ai didi

dart - BottomNavigationBarItem 中添加的四个图标不起作用

转载 作者:IT王子 更新时间:2023-10-29 06:49:59 24 4
gpt4 key购买 nike

我是 Flutter 的新手 我在尝试添加四个图标时创建了一个底部导航栏。图标颜色变为白色。我应该如何实现这一点,任何人都可以建议我。下面是我的代码。任何帮助将不胜感激。

 bottomNavigationBar: new BottomNavigationBar(items: [
new BottomNavigationBarItem(icon: new Icon(Icons.add), title: new Text("Text")),
new BottomNavigationBarItem(icon: new Icon(Icons.person), title: new Text("Contact")),
new BottomNavigationBarItem(icon: new Icon(Icons.accessibility), title: new Text("Acess")),
new BottomNavigationBarItem(icon: new Icon(Icons.account_balance), title: new Text("Balance"))
]),

最佳答案

当元素超过3个时,需要显式设置type: BottomNavigationBarType.fixed,

bottomNavigationBar: new BottomNavigationBar(
type: BottomNavigationBarType.fixed,
items: [
new BottomNavigationBarItem(icon: new Icon(Icons.add), title: new Text("Text")),
new BottomNavigationBarItem(icon: new Icon(Icons.person), title: new Text("Contact")),
new BottomNavigationBarItem(icon: new Icon(Icons.accessibility), title: new Text("Acess")),
new BottomNavigationBarItem(icon: new Icon(Icons.account_balance), title: new Text("Balance"))
]),

When more than 3 BottomNavigationBar items are provided the type, if unspecified, changes to BottomNavigationBarType.shifting per https://docs.flutter.io/flutter/material/BottomNavigationBar/BottomNavigationBar.html.

关于dart - BottomNavigationBarItem 中添加的四个图标不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51557712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com