BottomNavigationBar // 额外页面的问题
我使用 BottomNavigationBar + BottomNavigationBarItem 小部件在一个脚手架内切换页面。我的问题:
我还使用抽屉来提供导航选项。我能够使用与抽屉底部导航栏相同的页面列表。那行得通。但是:我现在想使用抽屉提供比底栏中更多的页面,并且一旦我想设置这些页面的索引,BottomNavigationBar 就会抛出错误:
'package:flutter/src/material/bottom_navigation_bar.dart': 失败 断言:第 192 行 pos 15: '0 <= currentIndex &&当前索引 < items.length': 不正确。
似乎发生的情况是,BottomNavigationBar 阻止我使用比连接到 Bottom Bar 的页面更多的页面。有办法解决这个问题吗?我不想在底部栏中出现超过 4 个符号,但我想要 5 页;如果可能的话,所有这些都在同一个脚手架中。谢谢!
I'm using the BottomNavigationBar + the BottomNavigationBarItem widget to switch through pages within one scaffold. My problem:
I'm also using a Drawer to give navigation options. I was able to use the same list of pages I use with the bottom navigation bar in the drawer. That works. But: I now want to use the drawer to offer more pages than in the bottom bar and as soon as I want to set the index to those pages, the BottomNavigationBar throws an error:
'package:flutter/src/material/bottom_navigation_bar.dart': Failed
assertion: line 192 pos 15: '0 <= currentIndex && currentIndex <
items.length': is not true.
What seems to happen is that the BottomNavigationBar is keeping me from using more pages than connected to the Bottom Bar. Is there anay way around this? I don't want more than 4 symbols in the bottom bar, but I want 5 pages; and if possible all of them in the same Scaffold. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为此,您需要逻辑地管理变量。这是一个完整的例子。
For making this you need to manage variables logically. Here is a complete example.
尝试这个方法——
Try this approach-