[英]customize bottom navigation in flutter
I'm working on a flutter project and I want to add a bottom navigation bar but I want to add a variable that show how many BottomNavigationBarItem
it will be in this bottom navigation bar, for example if I set a value to 5 I Will have 5 BottomNavigationBarItem
in my bottom navigation, if I change it to 3 I will have just 3. Is there a way to do it.我正在做一个颤振项目,我想添加一个底部导航栏,但我想添加一个变量来显示底部导航栏中将有多少BottomNavigationBarItem
,例如,如果我将值设置为 5,我将拥有5 BottomNavigationBarItem
在我的底部导航中,如果我将其更改为 3,我将只有 3。有没有办法做到这一点。 Any help is highly appreciated.非常感谢任何帮助。
Just declare a variable to store the count of the items in the BottomNavigationBar
and use it to generate the items.只需声明一个变量来存储BottomNavigationBar
中项目的数量并使用它来生成项目。
If the variable is changing dynamically and you want to reflect that change to the BottomNavigationBar
then set the widget containing the BottomNavigationBar
as a StatefulWidget
and follow the same concept in this answer to complete the rest of the task.如果变量是动态变化的,并且您希望将该更改反映到BottomNavigationBar
,则将包含BottomNavigationBar
的小部件设置为StatefulWidget
并遵循此答案中的相同概念来完成其余任务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.