BottomNavigationBar
Flutter's BottomNavigationBar widget is a material design widget that is used to display a horizontal row of buttons at the bottom of the screen, typically for navigation purposes.
Example:
BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Home',
),
BottomNavigationBarItem(
icon: Icon(Icons.favorite),
label: 'Favorites',
),
BottomNavigationBarItem(
icon: Icon(Icons.person),
label: 'Profile',
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
)In the above example, we have created a BottomNavigationBar widget with three buttons labeled 'Home', 'Favorites', and 'Profile', respectively. The _selectedIndex variable is used to keep track of the currently selected button, and the _onItemTapped function is called when a button is tapped.
Attributes
items: A required list ofBottomNavigationBarItemobjects that define the buttons to be displayed in the navigation bar.
currentIndex: An optional integer that specifies the index of the currently selected button.
onTap: An optional callback function that is called when a button in the navigation bar is tapped.
backgroundColor: An optional color that specifies the background color of the navigation bar.
elevation: An optional double that specifies the elevation of the navigation bar.
selectedItemColor: An optional color that specifies the color of the selected button in the navigation bar.
unselectedItemColor: An optional color that specifies the color of the unselected buttons in the navigation bar.
showSelectedLabels: An optional boolean that specifies whether to show the label for the selected button.
showUnselectedLabels: An optional boolean that specifies whether to show the label for the unselected buttons.