reevaluate method
Implementation
@override
void reevaluate(AutoRedirectGuardBase guard, StackRouter router) {
final routes = router.stackData.map((e) => e.route).toList();
final firstGuardedRouteIndex =
routes.indexWhere((r) => r.guards.contains(guard));
if (firstGuardedRouteIndex == -1) return;
final routesToRemove =
routes.sublist(firstGuardedRouteIndex, routes.length);
for (final route in routesToRemove) {
router._removeRoute(route, notify: false);
}
final routesToPush = <RouteMatch>[];
for (final existingMatch in routes.sublist(
firstGuardedRouteIndex,
routes.length,
)) {
final routeToPush = router.matcher.matchByRoute(
existingMatch.toPageRouteInfo(),
);
if (routeToPush != null) {
routesToPush.add(routeToPush);
}
}
router._pushAllGuarded(routesToPush);
}