Examples
You can see go_router in action via the following examples:
main.dart
: define a basic routing policy using a set of declarativeGoRoute
objectserror_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 aStream
to trigger a refresh instead of aListenable
loading_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 theNavigator
widgetshared_scaffold.dart
: show anavBuilder
implementation that shares a scaffold between pagesurl_strategy.dart
: turn off the # in the Flutter web URLuser_input.dart
: usingNavigator
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 buttonnav_observer.dart
: pass additional information to theNavigatorObserver
via 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