Current field guide · 2026
Name a destination once
A named route lets callers refer to a destination without repeating its path template.
On this page
Keep names unique
Give a route an unambiguous name, then pass pathParameters when navigating to it. The name identifies the configuration entry; it does not replace a resource identifier such as a book ID.
Generate a location when you need a link
Use namedLocation when you need a URI string for a link, a redirect, or another API. Supply optional query parameters explicitly. Keep encoded URLs out of handwritten interpolation whenever a routing or URI helper can construct them.
Names are not type checking
A misspelled string or missing parameter can still be an error. For larger route maps, generated type-safe routes can move more mistakes into analysis. That introduces a build step and should match your team's maintenance practices.
Test refactors as links
Renaming a Dart route name and changing a public URL are different migrations. Even if all internal call sites compile, previously distributed URLs still need a valid destination. Preserve meaningful legacy links when reorganizing your application.
GoRoute(
name: 'book',
path: '/books/:bookId',
builder: (_, state) => BookScreen(
id: state.pathParameters['bookId']!,
),
);
context.goNamed('book', pathParameters: {'bookId': '42'});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.