Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injecting arguments to page when navigating with AutoRouter() widget #2135

Open
AzarouAmine opened this issue Jan 22, 2025 · 0 comments
Open

Comments

@AzarouAmine
Copy link

AzarouAmine commented Jan 22, 2025

Is there a way to inject arguments to a page when we're using AutoRouter() widget in a page wrapper? For example with this configuration:

@AutoRouterConfig()
class AppRouter extends RootStackRouter {
  @override
  RouteType get defaultRouteType => const RouteType.material();

  @override
  List<AutoRoute> get routes => <AutoRoute>[
        AutoRoute(
          path: '/',
          page: InitialRoute.page,
          initial: true,
          children: <AutoRoute>[
            AutoRoute(page: ChildRoute.page),
            RedirectRoute(path: '*', redirectTo: ''),
          ],
        ),
      ];
}

And InitialPage being :

@RoutePage()
class InitialRoute extends StatelessWidget {
  const InitialRoute({super.key});

  @override
  Widget build(BuildContext context) {
    return WrapperWidget(
      child: AutoRouter(),
    );
  }
}

This means that ChildPage will be automatically shown when opening the app. However if we need to pass an argument to this page, how can this be done?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant