A Bottom Navigation Bar is a widget that displays navigation items at the bottom of the app screen. It helps users switch between different main sections of the app easily.
Click to reveal answer
beginner
Which Flutter widget is commonly used to create a Bottom Navigation Bar?
The BottomNavigationBar widget is used to create a Bottom Navigation Bar in Flutter.
Click to reveal answer
intermediate
How do you handle taps on Bottom Navigation Bar items in Flutter?
You use the onTap callback property of BottomNavigationBar. It gives the index of the tapped item, which you can use to update the UI or navigate.
Click to reveal answer
beginner
What property controls which Bottom Navigation Bar item is currently selected?
The currentIndex property controls which item is highlighted as selected in the Bottom Navigation Bar.
Click to reveal answer
beginner
Why is it important to keep Bottom Navigation Bar items to 3-5?
Keeping 3-5 items ensures the bar stays clear and easy to use. Too many items can clutter the bar and confuse users.
Click to reveal answer
Which widget creates a Bottom Navigation Bar in Flutter?
ADrawer
BAppBar
CBottomNavigationBar
DTabBar
✗ Incorrect
The BottomNavigationBar widget is specifically designed for bottom navigation in Flutter apps.
What property do you use to know which Bottom Navigation Bar item is selected?
AselectedItem
BhighlightIndex
CactiveTab
DcurrentIndex
✗ Incorrect
The currentIndex property tells Flutter which item is currently selected.
How do you respond when a user taps a Bottom Navigation Bar item?
AUse onTap callback
BUse onPressed callback
CUse onSelect callback
DUse onClick callback
✗ Incorrect
The onTap callback is used to detect taps on BottomNavigationBar items.
What is a good maximum number of items for a Bottom Navigation Bar?
A3-5
BMore than 8
C6-8
D2
✗ Incorrect
3 to 5 items keep the navigation bar simple and user-friendly.
Where is the Bottom Navigation Bar usually placed in an app?
AOn the left side
BAt the bottom of the screen
CAt the top of the screen
DFloating in the middle
✗ Incorrect
As the name says, the Bottom Navigation Bar is placed at the bottom of the screen.
Explain how to create a Bottom Navigation Bar in Flutter and handle item taps.
Think about how you show different pages when tapping different icons.
You got /5 concepts.
Why should you limit the number of items in a Bottom Navigation Bar? What happens if you add too many?
Imagine a messy menu versus a clean one.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of a BottomNavigationBar in a Flutter app?
easy
A. To let users switch between main sections of the app easily
B. To display a list of items vertically
C. To show a popup menu on tap
D. To create a floating action button
Solution
Step 1: Understand the role of BottomNavigationBar
The BottomNavigationBar widget is designed to help users navigate between main app sections by showing tabs at the bottom.
Step 2: Compare with other UI elements
Options B, C, and D describe different widgets or behaviors not related to bottom navigation bars.
Final Answer:
To let users switch between main sections of the app easily -> Option A
A. BottomNavigationBarItem requires a title property
B. Missing currentIndex property to reflect selected tab
C. onTap callback should return a value
D. Using const keyword inside items list
Solution
Step 1: Check required properties for BottomNavigationBar
The currentIndex property is needed to tell the widget which tab is active.
Step 2: Identify missing currentIndex usage
Without currentIndex, the UI won't update to show the selected tab visually.
Final Answer:
Missing currentIndex property to reflect selected tab -> Option B
Quick Check:
currentIndex must be set for selected tab highlight [OK]
Hint: Always set currentIndex to show active tab [OK]
Common Mistakes:
Forgetting currentIndex causes no visual update
Thinking onTap must return a value
Using deprecated title instead of label
5. You want to create a BottomNavigationBar with three tabs: Home, Search, and Profile. When a tab is tapped, the main content should update to show a different widget for each tab. Which approach correctly manages the state and updates the UI?
hard
A. Use a StatefulWidget but do not update _selectedIndex; just rebuild widgets conditionally
B. Use a StatelessWidget and update _selectedIndex variable directly inside onTap without setState
C. Use a StatefulWidget with an int _selectedIndex state; update _selectedIndex in onTap; use _selectedIndex to show different widgets in build method
D. Use a StatefulWidget and update _selectedIndex in onTap but do not call setState
Solution
Step 1: Understand state management for BottomNavigationBar
To update UI on tab tap, you must store selected tab index in state and update it properly.
Step 2: Use StatefulWidget and setState to update UI
Use a StatefulWidget with an int _selectedIndex state; update _selectedIndex in onTap; use _selectedIndex to show different widgets in build method correctly uses StatefulWidget, updates _selectedIndex inside onTap, and calls setState to rebuild UI with new content.
Final Answer:
Use a StatefulWidget with an int _selectedIndex state; update _selectedIndex in onTap; use _selectedIndex to show different widgets in build method -> Option C