
To make this possible, we only needed a few ingredients: Note how the counter value is preserved when switching between tabs Here’s what the end result looks like: Stateful nested navigation example. Stateful nested navigation “just works”, and each branch remembers its own state (all the pages inside each tab).

#FLUTTER SCAFFOLD BOTTOMNAVIGATIONBAR UPDATE#
What’s great about using navigationShell is that we don’t have to store and update any state (such as the selected index) inside our ScaffoldWithNestedNavigation (which is a StatelessWidget).

Scaffold ( body: navigationShell, bottomNavigationBar: NavigationBar ( selectedIndex: navigationShell. settings )), ], onDestinationSelected: ( index ) Īs we can see, the navigationShell is passed directly to the body of the Scaffold:

home )), NavigationDestination ( label: 'Section B', icon: Icon ( Icons. Scaffold ( body: /* TODO: decide which page to show, depending on the selected index */, bottomNavigationBar: NavigationBar ( selectedIndex: /* TODO: where does this come from? */, destinations: const widget NavigationDestination ( label: 'Section A', icon: Icon ( Icons.
