go_router

Examples

You can see go_router in action via the following examples:

  • main.dart: define a basic routing policy using a set of declarative GoRoute objects
  • error_screen.dart: define a custom error screen for use when there's a routing or builder error
  • init_loc.dart: start at a specific location instead of home (/), which is the default
  • sub_routes.dart: provide a stack of pages based on a set of sub routes
  • push.dart: provide a stack of pages based on a series of calls to context.push()
  • redirection.dart: redirect one route to another based on changing app state
  • query_params.dart: optional query parameters will be passed to all builders
  • router_stream_refresh.dart: use a Stream to trigger a refresh instead of a Listenable
  • loading_page.dart: load a repository once the user has logged in, showing a loading screen while they wait
  • named_routes.dart: navigate via name instead of location URI
  • transitions.dart: use custom transitions during routing
  • async_data.dart: async data lookup
  • nested_nav.dart: include information about children on a page as part of the route location
  • nav_builder.dart: inject widgets above the Navigator widget
  • shared_scaffold.dart: show a navBuilder implementation that shares a scaffold between pages
  • url_strategy.dart: turn off the # in the Flutter web URL
  • user_input.dart: using Navigator or a go_router route to navigate to a page that gathers user input as well as canceling a pop when the user presses the Back button
  • nav_observer.dart: pass additional information to the NavigatorObserver via default args to MaterialPage, etc.
  • state_restoration.dart: test to ensure that go_router works with state restoration (it does)
  • cupertino.dart: test to ensure that go_router works with the Cupertino design language as well as Material (it does)
  • widgets_app.dart: test to ensure that go_router works with the WidgetsApp as well as the MaterialApp (it does)
  • router_neglect.dart: prevent the browser from creating history entries when navigating
  • books/main.dart: port of the navigation_and_routing sample to use go_router

You can run these examples from within your IDE of choice or from the example folder via the command line:

$ cd example
$ flutter run lib/main.dart