Navbar Notifier

Navbar Notifier is a secret sauce of this package where all the magic happens, from popping routes in tabs, hide/unhide bottom navbar to intercepting back button press events on android and much more. And more importantly this class is accessible to your app from any part of your application. This page demonstrates the usage of this class.

Pop routes from any tab

NavbarRouter gives you the control to manage the routes in any tab. You can pop route(s) from any tab using the NavbarNotifier class.

Pop the current route from a tab

   await NavbarNotifier.popRoute(index);

Pop all routes from a tab

   await NavbarNotifier.popAllRoutes(index);

Hide/Show Bottom Navbar

NavbarRouter gives you the ability to hide or show the bottom navbar. You can hide or show the bottom navbar using the hideBottomNavBar setter.

Hide Bottom Navbar

    NavbarNotifier.hideBottomNavBar = true;

Show Bottom Navbar

    NavbarNotifier.hideBottomNavBar = false;

Programmatically change the current index

NavbarRouter gives you the control to change the current index of the bottom navbar. You can change the current index of the bottom navbar using the index setter of the NavbarNotifier class.

Sets the current index of the bottom navbar to 1.

   NavbarNotifier.index = 1;

Navbar index change Listener

You can listen to the index change events of the bottom navbar using the addIndexChangeListener method of the NavbarNotifier class.

    NavbarNotifier.addIndexChangeListener((x) {
      print('NavbarNotifier.indexChangeListener: $x');
    });

The Notifier is capable of handling multiple listeners. You can add as many listeners as you want.

Note: You should ensure that you remove the listener when you are done with it.

You can remove the listener using the removeLastListener or using removeAllListeners to remove all listeners method of the NavbarNotifier class.

NavbarNotifier.removeAllListeners();

Show/Hide the SnackBar

NavbarRouter gives you the ability to show or hide the SnackBar. You can show or hide the SnackBar using the showSnackBar and hideSnackBar methods of the NavbarNotifier class.

Show the SnackBar

    NavbarNotifier.showSnackBar(
      context,
      'This is a SnackBar',
      duration: Duration(seconds: 2),
    );

Hide the SnackBar

    NavbarNotifier.hideSnackBar(context);