Skip to content

[go_router] Redirect examples in documentation use incorrect method signature #112754

@ryan-andrew

Description

@ryan-andrew

All of the examples in the documentation for the redirect field on the GoRouter class now use the incorrect signature.

One such example from the docs:

final GoRouter _router = GoRouter(
  routes: <GoRoute>[
    GoRoute(
      path: '/',
      redirect: (_) => '/family/${Families.data[0].id}',
    ),
    GoRoute(
      path: '/family',
      pageBuilder: (BuildContext context, GoRouterState state) => ...,
    ),
    GoRoute(
      path: '/:username',
      pageBuilder: (BuildContext context, GoRouterState state) => ...,
    ),
  ],
);

The GoRouterRedirect callback now takes a BuildContext in addition to the GoRouterState that was there before.

For the examples to compile, we would need to change the constructor parameter to something like:

redirect: (_, __) => '/family/${Families.data[0].id}',

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listd: examplesSample code and demosp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions