name property

String? name
finalinherited

Optional name of the route.

If used, a unique string name must be provided and it can not be empty.

This is used in GoRouter.namedLocation and its related API. This property can be used to navigate to this route without knowing exact the URI of it.

{@tool snippet} Typical usage is as follows:

GoRoute(
  name: 'home',
  path: '/',
  builder: (BuildContext context, GoRouterState state) =>
      HomeScreen(),
  routes: <GoRoute>[
    GoRoute(
      name: 'family',
      path: 'family/:fid',
      builder: (BuildContext context, GoRouterState state) =>
          FamilyScreen(),
    ),
  ],
);

context.go(
  context.namedLocation('family'),
  pathParameters: <String, String>{'fid': 123},
  queryParameters: <String, String>{'qid': 'quid'},
);

{@end-tool}

See the named routes example for a complete runnable app.

Implementation

final String? name;