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

Nested routes being separate #2029

Open
tomassasovsky opened this issue Aug 6, 2024 · 3 comments
Open

Nested routes being separate #2029

tomassasovsky opened this issue Aug 6, 2024 · 3 comments

Comments

@tomassasovsky
Copy link

Does this package support nested routes similar to go_router's children routes? I've tried the children argument with AutoRouter but they don't behave anything alike.

Example:

Considering the following go_router code:

final _router = GoRouter(
  routes: [
    GoRoute(
      path: '/',
      builder: (context, state) => HomeScreen(),
      children: [
        GoRoute(
          path: 'account'
          builder: (context, state) => AccountScreen(),
        ),
      ],
    ),
  ],
);

I can push from the HomeScreen to the AccountScreen, and then pop. I can even open the /account deep link and be able to pop because the account route is separate from the / route. Is this not achievable in auto_route?

@BarashkovaElena
Copy link

Auto route seem to handle these cases differently.
In go router, you need to keep the strict hierarchy. In auto route, you don't have to. Just place both pages on the same level and push them in any order you like.
Use children for things like bottom bar navigation.

@tomassasovsky
Copy link
Author

That does not work for the behaviour I need, which is popping from one child route to its parent automatically. Will there be no support for this in the future?

@BarashkovaElena
Copy link

BarashkovaElena commented Aug 21, 2024

That does not work for the behaviour I need, which is popping from one child route to its parent automatically. Will there be no support for this in the future?

Have you tried this?

       AutoRoute(
              initial: true,
              path: '/',
              page: HomeTabRoute.page,
              children: [
                AutoRoute(page: HomeRoute.page, initial: true),
                AutoRoute(page: AccountRoute.page, path: 'account'),
              ],
            ),

Then HomePage is opened when you open your app.
Calling context.router.push(AccountRoute()); will open AccountPage.
Calling context.router.maybePop() after that will close AccountPage and return to HomePage.
Not sure about how '/account' deeplink will work in this case, need to test.

Alternatively, there is app_links package that can help you to customize deep links handling.
I didn't dig very deep into the deeplink handling in this package. Reverted to go_router in the end.

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

2 participants