<p>In this example, I'm going to share the code on how to add an indicator to Bottomnavigationbar in flutter. Here is the output of what you are going to achieve from this example.</p> <p> { runApp(App()); }</p> <p>class App extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData(), home: MainPage(), ); } }</p> <p>class MainPage extends StatefulWidget { @override _MainPageState createState() => _MainPageState(); }</p> <p _selectedIndex="value;">class _MainPageState extends State { int _selectedIndex = 0; void _onItemTappped(int value) { setState(() ); }</p> <p>@override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: BottomNavigationBar( items: [ BottomNavigationBarItem( icon: Icon(Icons.home), title: showIndicator(_selectedIndex == 0)), BottomNavigationBarItem( icon: Icon(Icons.access_alarm), title: showIndicator(_selectedIndex == 1)), BottomNavigationBarItem( icon: Icon(Icons.settings), title: showIndicator(_selectedIndex == 2)), ], onTap: _onItemTappped, currentIndex: _selectedIndex, ), ); } }</p> <p>Widget showIndicator(bool show) { return show ? Padding( padding: const EdgeInsets.only(top: 4), child: Icon(Icons.brightness_1, size: 10, color: Colors.orange), ) : SizedBox(); }</p> <p>`</p> <p>Hope this post is useful to you. Thanks, Srikanth</p>
How to add an indicator to BottomNavigationBar?
This Article is posted by seven.srikanth at 3/25/2020 3:13:30 AM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags: BottomNavigationBar;
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter