0

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.

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.