/go_router_samples

sample repository for trying out StatefulShellRoute

Primary LanguageDart

Testing out StatefulShellRoute

This is a sample repository dedicated for article below regarding the use of StatefulShellRoute.

https://zenn.dev/flutteruniv_dev/articles/stateful_shell_route

StatefulShellRoute is a new feature added to go_router package in 2024/07, which allows us to easily implement persisted bottom navigation and persisted state of each tabs.

It'll be implemented in following steps.

  1. Define GoRouter
  2. Add StatefulShellRoute to it's route
  3. Prepare a page with NavigationBar and set it as root container for StatefulShellRoute
  4. Add StatefulShellBranch for each tabs
  5. Add GoRoute for each branches
  6. Set GlobalKey<NavigatorState> to each routes

Sample

After a dummy signin page, sample navigates to a page implemented with StatefulShellRoute.

Sample consists of four tabs which holds different types of states.

You can see how states for each tab is maintained even switching between tabs.

signin → bottom navigation app_bar counter nested navigation scroll