Milad-Akarie / auto_route_library

Flutter route generator
MIT License
1.59k stars 405 forks source link

Deep link navigation with AutoTabsScaffold; Consider making PlatformDeepLink constructor public #1832

Open PawlikMichal25 opened 10 months ago

PawlikMichal25 commented 10 months ago

Problem

We're using AutoTabsScaffold with following configuration:

    AutoRoute(
      path: mainPath,
      page: MainRoute.page,
      children: [
        AutoRoute(path: 'orders', page: OrdersRoute.page),
        AutoRoute(path: 'trades', page: TradesRoute.page),
      ],
    ),

and when user clicks deep link to nested tab, then we return eg. DeepLink([OrdersRoute()]) in deepLinkBuilder. This opens a new MainPage with OrdersRoute, which means that user ends up with 2 MainPages.

Possible solution

I think the easiest solution would be to return PlatformDeepLink([OrdersRoute()]) so that here https://github.com/Milad-Akarie/auto_route_library/blob/master/auto_route/lib/src/router/controller/auto_router_delegate.dart#L171 .navigateX() is used instead of .pushX(), but PlatformDeepLink has private constructor.

@Milad-Akarie, would you please consider:

tyler401go commented 1 month ago

@Milad-Akarie Bumping this, it would be nice to be able to specify push/navigate, or just make constructors public. Also, having all the different DeepLink implementations private makes it very inconvenient to test. I want to write some unit tests to make sure my deepLinkBuilder is returning correct links, but cannot access any of the fields in the return value.

jtdLab commented 1 month ago

@Milad-Akarie can this be fixed so its possible to pick wether to navigate/push RouteDeeplinks