Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java for Android
  • Android Studio
  • Android Kotlin
  • Kotlin
  • Flutter
  • Dart
  • Android Project
  • Android Interview
Open In App
Next Article:
Flutter - BoxDecoration Widget
Next article icon

BottomNavigationBar Widget in Flutter

Last Updated : 28 Feb, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

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

Syntax
BottomNavigationBar BottomNavigationBar({   Key? key,   required List<BottomNavigationBarItem> items,   void Function(int)? onTap,   int currentIndex = 0,   double? elevation,   BottomNavigationBarType? type,   Color? fixedColor,   Color? backgroundColor,   double iconSize = 24.0,   Color? selectedItemColor,   Color? unselectedItemColor,   IconThemeData? selectedIconTheme,   IconThemeData? unselectedIconTheme,   double selectedFontSize = 14.0,   double unselectedFontSize = 12.0,   TextStyle? selectedLabelStyle,   TextStyle? unselectedLabelStyle,   bool? showSelectedLabels,   bool? showUnselectedLabels,   MouseCursor? mouseCursor,   bool? enableFeedback,   BottomNavigationBarLandscapeLayout? landscapeLayout,   bool useLegacyColorScheme = true, }) 

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:

Dart
import 'package:flutter/material.dart';  // Entry point of the application void main() => runApp(const MyApp());  // Main application widget class MyApp extends StatelessWidget {   static const String _title = 'Flutter BottomNavigationBar';    const MyApp({super.key});    @override   Widget build(BuildContext context) {     return const MaterialApp(       title: _title,       home: MyStatefulWidget(),     );   } }  // Stateful widget to manage the // state of the BottomNavigationBar class MyStatefulWidget extends StatefulWidget  {   const MyStatefulWidget({super.key});    @override   _MyStatefulWidgetState createState() => _MyStatefulWidgetState(); }  class _MyStatefulWidgetState extends State<MyStatefulWidget> {        // Index to keep track of the selected tab   int _selectedIndex = 0;     // TextStyle for the text displayed in each tab   static const TextStyle optionStyle =       TextStyle(fontSize: 30, fontWeight: FontWeight.bold);    // List of widgets to display in each tab   static const List<Widget> _widgetOptions = <Widget>[     Text(       'HOME PAGE',       style: optionStyle,     ),     Text(       'COURSE PAGE',       style: optionStyle,     ),     Text(       'CONTACT GFG',       style: optionStyle,     ),   ];    // Method to handle tab selection   void _onItemTapped(int index) {     setState(() {       _selectedIndex = index;     });   }    @override   Widget build(BuildContext context) {     return Scaffold(       appBar: AppBar(         title: const Text(           'GeeksForGeeks',           style: TextStyle(             color: Colors.white,           ),         ),         backgroundColor: Colors.green,       ),       body: Center(         child: _widgetOptions.elementAt(_selectedIndex),       ),       bottomNavigationBar: BottomNavigationBar(         items: const <BottomNavigationBarItem>[           BottomNavigationBarItem(             icon: Icon(Icons.home),             label: 'Home',           ),           BottomNavigationBarItem(             icon: Icon(Icons.bookmark),             label: 'Courses',           ),           BottomNavigationBarItem(             icon: Icon(Icons.contact_mail),             label: 'Mail',           ),         ],         currentIndex: _selectedIndex,         selectedItemColor: Colors.amber[800],         onTap: _onItemTapped,       ),     );   } } 

 
 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.
     


Next Article
Flutter - BoxDecoration Widget

D

ddeevviissaavviittaa
Improve
Article Tags :
  • Android
  • Flutter
  • Flutter
  • Flutter-Widgets

Similar Reads

  • Flutter - CupertinoNavigationBar Widget
    The CupertinoNavigationBar widget in Flutter is a part of the Cupertino package, which is designed to provide an iOS-style look and feel to your Flutter app. This widget represents the navigation bar that is typically found at the top of an iOS app's screen. In this article, we are going to implemen
    3 min read
  • Flutter - Loading Animation Widget
    In every mobile application, there is a loading animation with different colors and styles, basically, we use the loading animation when we are waiting for something. Like if we are fetching the data from the database then we have to wait for some time until the data is not fetched. So in this durat
    3 min read
  • Flutter - BoxDecoration Widget
    BoxDecoration is a build-in widget in flutter API. At a bare basic level, it describes how a box should be painted on the screen. The shape of the box needs not to be just a rectangle or a square it can circle also. It comes with a ton of properties we can add an image inside, add a radius to the bo
    3 min read
  • FlatButton Widget in Flutter
    FlatButton is the material design widget in a flutter. It is a text label material widget that performs an action when the button is tapped. Let's understand with the help of examples.  Disclaimer: As of May 2021 the FlatButton class in flutter is deprecated. TextButton class should be used instead.
    3 min read
  • Center widget in Flutter
    Center widget comes built-in with flutter, it aligns its child widget to the center of the available space on the screen. The size of this widget will be as big as possible if the widthFactor and heightFactor properties are set to null and the dimensions are constrained. And in case the dimensions a
    2 min read
  • Draggable Widget in Flutter
    In Flutter, a Draggable widget can be used to allow users to interact with a widget by dragging it around the screen. To create a Draggable widget, you can use the Draggable class and pass it to a child widget to be rendered, along with a feedback widget that will be displayed while the user is drag
    4 min read
  • Flutter - AnimatedIcon Widget
    Animation has become a vital part of UI design, whether it be a transition from one window to another or the closing of the window, the animation plays an important role in the smooth representation of the process. Just like that when we click on the icon, it shows animation, or another icon is show
    3 min read
  • Flutter - Outputting Widgets Conditionally
    One of the best things about using Flutter is the control it gives you over the UI. You can easily show a loading spinner, hide buttons until a form is complete, or change views based on user selections. In this guide, we'll cover various ways to conditionally display widgets, from simple if stateme
    6 min read
  • Raised Button widget in Flutter
    RaisedButton is the material design button based on a Material widget that elevates when pressed upon in flutter. It is one of the most widely used buttons in the flutter library. Let's understand this button with the help of an example. Disclaimer: As of May 2021 the RaisedButton class in flutter i
    5 min read
  • Flutter - BorderDirectional Widget
    BorderDirectional is a built-in widget in flutter SDK. This widget is somewhat similar to the Border widget with the main difference being the inclusion of start and end property which lets the user modify the border according to the text direction right-to-left (rtl) or left-to-right (ltr). If our
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences