问题描述
我是新手,一直在尝试使用BottomNavigationBar
。事情是,我按要求制作了酒吧,但是当Switch
设置为true却无法找到解决方法时,我需要它来更新其项目。
我有两个List<BottomNavigationBarItems>
,它们有两个不同的navBar项,我将它们分配给第三个列表,该列表包含根据开关状态的活动项。这个变量是在我的navbarItem中设置项目的变量,但是setState()
似乎并没有重新构建navBar。
是否有一种方法可以更新项目,或者我必须与其他小部件一起制作自己的navBar?
List<BottomNavigationBarItem> nonReadyBottomItems = [
//some items
];
List<BottomNavigationBarItem> readyBottomItems = [
some other items
];
List<BottomNavigationBarItem> = nonReadyBottomItems;
Scaffold(
body: Center(
child: Switch(
value: switchConnect,onChanged: (bool boolean) {
setState(() {
switchConnect = boolean;
});
}),),bottomNavigationBar: BottomNavigationBar(
onTap: (int i) {
setState(() {
pageIndex = i;
if (switchConnect) {
activeItems = readyBottomItems;
} else if (!switchConnect) {
activeItems = nonReadyBottomItems;
}
});
},currentIndex: pageIndex,type: BottomNavigationBarType.fixed,items: activeItems,);
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)