VOOZH about

URL: https://www.geeksforgeeks.org/flutter/bottomnavigationbar-widget-in-flutter/

⇱ BottomNavigationBar Widget in Flutter - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

BottomNavigationBar Widget in Flutter

Last Updated : 28 Feb, 2025

The BottonNavigationBar widget is used to show the bottom of an app. It consist of multiple items such as icons, texts or labels, or both, that leads to a different route depending upon the design of the application. It is meant to help the user navigate to different sections of the application in general.

Constructor

Properties

Properties

Description

key

Controls how one widget replaces another widget in the tree.

backgrounColor

The color of the BottomNavigationBar itself.

elevation

The z-coordinate of this BottomNavigationBar.

fixedColor

it defines the selected Item Color in bottom navigation bar.

items

Defines the appearance of the button items that are arrayed within the bottom navigation bar.

onTap

Called when one of the items is tapped.

currentIndex

it takes an int value as the object to determine the current index of BottomNavigationBarItem list.

iconSize

It takes a double value as the object to determine the size of all the icons in the BottomNavigationBar.

mouseCursor

The mouseCursor property takes MouseCursor class as the object. It determines the type of cursor this widget will have when you hovering on bottom navigation bar.

selectedFontSize

This property controls the font size in the BottomNavigationBar when the items are selected. It takes a double value as the object.

selectedIcontheme

This property holds IconThemeData class as the object to controls the appearance of the icons like size, color, opacity when it is selected.

selectedItemColor

This property determines the color of the icons and label when they are selected. This property takes Color class as the property.

selectedLabelStyle

TextStyle class is the object assigned to this property which controls the text style when they are selected.

showSelectedLabels

This property takes a boolean value as the object to determine whether the labels for the selected item will be shown or not.

showUnselectedLabels

This property also takes in a boolean value as the object to determine whether the labels for unselected items will be shown or not.

type

The type property controls the behaviour and the layout of the BottomNavigationBar. It takes BottomNavigationBarType enum as the object.

unselectedFontSize

This property also takes a double value as an object to determine the size of label when the item is not selected.

unselectedIconTheme

This property also holds IconThemeData class as the object to controls the appearance of the icons like size, color, opacity when it is unselected or not selected.

unselectedItemColor

This property determines the color the icons and label when they are unselected. This property takes Color class as the property.

unselectedLabelStyle

TextStyle class is the object assigned to this property which controls the text style when the item is unselected.


Example of BottomNavigationBar Widget in Flutter

Below is the implementation of BottomNavigationBar:


Output:

Explanation of the above Program:

  1. First, create the stateless main widget.
  2. Second use the stateful widget to create an appbar, bottomNavigationBar inside the scaffold.
  3. Third use the ButtomNavigationBar widget in the Scaffold.
  4. Do not forget to use setstate to change the current indexes of bottomNavigationBar.
Comment
Article Tags:

Explore