Current field guide · 2026
Think in destinations
A route configuration describes which screens belong to a location; navigation changes that location.
On this page
Separate location from screen state
The path identifies the destination. A selected sort order can live in the query string. A text cursor, a temporarily expanded panel, or an animation progress usually belongs to the screen instead. Putting every transient detail in the URL makes links noisy; keeping every durable choice outside it makes links impossible to share.
Describe the hierarchy
A child route can build a screen above its matched parent. A shell supplies shared navigation around its children. These are different relationships: use the route tree to express which screen history should exist, and a shell when a persistent frame should remain visible.
Keep builders predictable
Builders turn route state into widgets. Fetching data or performing a sign-in belongs to application services and screen lifecycle, rather than an unrepeatable side effect in a route builder. The router may evaluate configuration again when navigation or dependencies change.
Make the model observable
Switch on diagnostics during development. If a route behaves unexpectedly, compare the requested URI with the matched route hierarchy before adding manual Navigator operations.
GoRoute(
path: '/books',
builder: (_, __) => const BookListScreen(),
routes: [
GoRoute(
path: ':bookId',
builder: (_, state) => BookScreen(
id: state.pathParameters['bookId']!,
),
),
],
)Sources & version context
GoRouter.dev documentation edition. Examples illustrate the APIs described in the linked primary documentation. Adapt application-owned widgets and services to your project. They are not an executed Flutter session in this browser.