DEV Community

Akash Pattnaik
Akash Pattnaik

Posted on

The new BottomBar in Flutter

Hello fam 👋!

This tutorial shows the new BottomBar implementation in flutter. (It's official).

This is a new Material UI 3 implementation and is recommended to have only 3 childs (NavigationDestination).

For further lookup you can see here.

Here's a sample code that I used...

class AppHomePage extends StatefulWidget {
  const AppHomePage({super.key});

  State<AppHomePage> createState() => _AppHomePageState();

class _AppHomePageState extends State<AppHomePage> {
  Widget build(BuildContext context) {
    return Scaffold(
      body: const SizedBox(),
      // Here
      bottomNavigationBar: NavigationBar(
          overlayColor: MaterialStateProperty.all(Colors.yellow),
          selectedIndex: _selectedIndex,
          onDestinationSelected: (int index) {
            setState(() {
              _selectedIndex = index;
          // indicatorColor:,
          destinations: const [
              icon: Icon(CupertinoIcons.home),
              selectedIcon: Icon(CupertinoIcons.house_fill),
              label: 'Home',
              icon: Icon(Icons.explore_outlined),
              selectedIcon: Icon(Icons.explore_rounded),
              label: 'Explore',
              icon: Icon(CupertinoIcons.bookmark),
              selectedIcon: Icon(CupertinoIcons.bookmark_solid),
              label: 'Saved',
              icon: Icon(CupertinoIcons.person),
              selectedIcon: Icon(CupertinoIcons.person_fill),
              label: 'Account',
Enter fullscreen mode Exit fullscreen mode

Top comments (0)