Historical source · 2021–2022
Examples · 2021-12-29 snapshot
A readable historical capture of the original examples documentation, recovered on 22 October 2026.
On this page
Historical Wayback capture. Original APIs and dates are preserved; use the current guide for modern code. Scripts and old search configuration are excluded from this reader.
Examples
You can see go_router in action via the following examples:
main.dart: define a basic routing policy using a set of declarativeGoRouteobjectserror_screen.dart: define a custom error screen for use when there's a routing or builder errorinit_loc.dart: start at a specific location instead of home (/), which is the defaultsub_routes.dart: provide a stack of pages based on a set of sub routespush.dart: provide a stack of pages based on a series of calls tocontext.push()redirection.dart: redirect one route to another based on changing app statequery_params.dart: optional query parameters will be passed to all buildersrouter_stream_refresh.dart: use aStreamto trigger a refresh instead of aListenableloading_page.dart: load a repository once the user has logged in, showing a loading screen while they waitnamed_routes.dart: navigate via name instead of location URItransitions.dart: use custom transitions during routingasync_data.dart: async data lookupnested_nav.dart: include information about children on a page as part of the route locationnav_builder.dart: inject widgets above theNavigatorwidgeturl_strategy.dart: turn off the # in the Flutter web URLnavigator_integration.dart: usingNavigatorto navigate to a page that gathers user inputnav_observer.dart: pass additional information to theNavigatorObservervia default args toMaterialPage, 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 theMaterialApp(it does)router_neglect.dart: prevent the browser from creating history entries when navigatingbooks/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
Edit this pagePowered bydocs.pageSources & version context
GoRouter.dev documentation edition. The preserved text describes the original package APIs. Follow the current guide before using it in a new project.