beatfloraminederecho
beatfloraminederecho

Reputation: 231

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

Upvotes: 0

Views: 117

Answers (1)

Moaz El-sawaf
Moaz El-sawaf

Reputation: 3039

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.

Upvotes: 3

Related Questions