stacked icon indicating copy to clipboard operation
stacked copied to clipboard

[stacked_services] 0.8.3 currentRoute doesn't work for nested routes

Open bbedward opened this issue 5 years ago • 4 comments

Relevant to #218, currentRoute still doesn't work as expected for nested routes.

Having routes such as:

  MaterialRoute(page: LoginView, initial: true),
  MaterialRoute(
    page: DrawerNavigatorView,
    children: [
      CustomRoute(page: HomeView, initial: true),
      CustomRoute(page: ReportsView),
      CustomRoute(page: TeamView),
      CustomRoute(page: SettingsView),
      CustomRoute(page: SupportView),
    ],
  ),

When on one of the nested routes, e.g. HomeView, ReportsView, TeamView the currentRoute is always /drawer-navigator-view. In our case at least it would be desired to get information about the current nested route as well.

bbedward avatar Apr 14 '21 13:04 bbedward

Please try passing StackedService.routeObserver into your ExtendedNavigator 's observers

hurbes avatar Apr 16 '21 16:04 hurbes

@hurbes I'm not really sure what you mean, use it somewhere other than the MaterialApp?

bbedward avatar Apr 16 '21 16:04 bbedward

You are using ExtendedNavigator for those nested routes, right? Try passing the StackedService.routeObserver in its observers like this

ExtendedNavigator<HomeViewRouter>(
      router: HomeViewRouter(),
      initialRoute: Routes.streamCounterView,
      observers: [StackedService.routeObserver],
      navigatorKey: StackedService.nestedNavigationKey(1),
 );

hurbes avatar Apr 16 '21 16:04 hurbes

Ah yes, that works. Thank you

bbedward avatar Apr 16 '21 16:04 bbedward