Home > Enterprise >  customize bottom navigation in flutter
customize bottom navigation in flutter

Time:06-02

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. Any help is highly appreciated.

CodePudding user response:

Just declare a variable to store the count of the items in the BottomNavigationBar and use it to generate the items.

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.

  • Related