didPush method

  1. @override
void didPush(
  1. Route route,
  2. Route? previousRoute
)
override

The Navigator pushed route.

The route immediately below that one, and thus the previously active route, is previousRoute.

Implementation

@override
void didPush(Route<dynamic> route, Route<dynamic>? previousRoute) {
  super.didPush(route, previousRoute);
  final newRoute = _RouteData.ofRoute(route);

  if (newRoute.isBottomSheet || newRoute.isDialog) {
    logV("OPEN ${newRoute.name} => args: ${routing?.args}");
  } else if (newRoute.isPageRoute) {
    logV("GOING TO ROUTE ${newRoute.name} => args: ${routing?.args}");
  }

  RouterReportManager.reportCurrentRoute(route);
  routing?.update((value) {
    // Only PageRoute is allowed to change current value
    if (route is PageRoute) {
      value.current = newRoute.name ?? '';
    }
    final previousRouteName = _extractRouteName(previousRoute);
    if (previousRouteName != null) {
      value.previous = previousRouteName;
    }

    value.route = route;
    value.isBack = false;
    value.removed = '';
    value.isBottomSheet =
        newRoute.isBottomSheet ? true : value.isBottomSheet ?? false;
    value.isDialog = newRoute.isDialog ? true : value.isDialog ?? false;
  });

  if (routing != null) {
    Go.routingQueue.add(routing!.copyWith());
  }
}