Source: https://gorouter.dev/examples ยท 20211229230302. Scripts, search configuration and interface chrome omitted; content retained.
You can see go_router in action via the following examples:
main.dart:
define a basic routing policy using a set of declarative GoRoute 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 to context.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 a Stream to trigger a refresh instead of a Listenableloading_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 the Navigator widgeturl_strategy.dart:
turn off the # in the Flutter web URLnavigator_integration.dart:
using Navigator to navigate to a page that gathers user inputnav_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 navigatingbooks/main.dart:
port of the
navigation_and_routing
sample to use go_routerYou 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.page