subscribe method
Subscribe AutoRouteAware to be informed about changes to route
.
Going forward, AutoRouteAware will be informed about qualifying changes
to route
, e.g. when route
is covered by another route or when route
is popped off the Navigator stack.
Implementation
void subscribe(AutoRouteAware routeAware, RouteData route) {
final Set<AutoRouteAware> subscribers = _listeners.putIfAbsent(route.key, () => <AutoRouteAware>{});
if (subscribers.add(routeAware)) {
final router = route.router;
if (router is TabsRouter) {
final previousIndex = router.previousIndex;
if (previousIndex != null && previousIndex >= 0 && previousIndex < router.stackData.length) {
final previousRoute = TabPageRoute(
routeInfo: router.stackData[previousIndex].route,
index: previousIndex,
);
routeAware.didInitTabRoute(previousRoute);
} else {
routeAware.didInitTabRoute(null);
}
} else {
routeAware.didPush();
}
}
}