auto_route_library
auto_route_library copied to clipboard
AutoTabsRouter is not invoking builder when children are pushed inside tab
Hi, the issue name is self-explanatory. Why this matters - I want to hide the bottom tab bar when a specific route is being pushed but it does not invoke the build method. Maybe for this specific case to hide the bottom tab bar it would nice to provide a callback which is invoked each time the navigation stack is updated?
Im having the same issue with trying to conditionally set the leading attribute on the AppBar. Not found any solutions but would be interested in the solution
@tapkain @lloydrichards if you watch any router you'll get a rebuild everytime the stack changes.
context.watchRouter.topRoute;
// or
context.watchTabsRouter.topRoute;
what I usually do is watch the topRoute directly
final hideNavBar = context.topRoute.name == FullScreenRoute.name;
I have this tabs router
AutoTabsScaffold(
homeIndex: 0,
routes: const [
ExploreTab(),
RadarTab(),
CreatePostTab(),
NotificationsTab(),
CurrentUserTab(),
],
bottomNavigationBuilder: (context, tabsRouter) {
if (context.topRouteMatch.meta[kHideBottomBar] == true) {
return const SizedBox.shrink();
}
return HomeBottomNavigationBar(
tabsRouter: tabsRouter,
);
},
);
routes declarations
AutoRoute<void>(
initial: true,
page: HomePage,
guards: [AuthGuard],
children: [
AutoRoute<void>(
name: 'ExploreTab',
page: EmptyRouterPage,
children: [
AutoRoute<void>(page: ExploreBinding, initial: true),
AutoRoute<void>(page: TopUsersBinding),
AutoRoute<void>(page: TopMoodsBinding),
AutoRoute<void>(page: UserBinding),
AutoRoute<void>(page: MoodBinding),
AutoRoute<void>
page: RatePostBinding,
meta: <String, dynamic>{
kHideBottomBar: true,
},
),
],
),
...other children here
topRoute extension for context is already watching router btw. When I'm pushing RatePostBinding which had the meta property, no bottomNavigationBuilder is invoked. So this is the issue in a nutshell.
@tapkain guess I'm gonna make both appBar and bottomNavigation builders rebuild on global stack changes.
@tapkain check out the new version
auto_route: 3.0.2
please close if this resolves your issue.
tried 3.03, still does not trigger the method.
from what I see, the main change was this line, right?
final parentScope = RouterScope.of(context, watch: true);
HEY FLUTTER WEB DEVS! After days of toubleshooting I've found the problem, when dealing with meta on a child route, make sure the child route has a path name like /task.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions