didPop method

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

The Navigator popped route.

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

Implementation

@override
void didPop(Route route, Route? previousRoute) {
  super.didPop(route, previousRoute);
  final currentRoute = _RouteData.ofRoute(route);
  final newRoute = _RouteData.ofRoute(previousRoute);

  // if (currentRoute.isSnackbar) {
  //   // Get.log("CLOSE SNACKBAR ${currentRoute.name}");
  //   Get.log("CLOSE SNACKBAR");
  // } else

  if (currentRoute.isBottomSheet || currentRoute.isDialog) {
    Get.log("CLOSE ${currentRoute.name}");
  } else if (currentRoute.isGetPageRoute) {
    Get.log("CLOSE TO ROUTE ${currentRoute.name}");
  }
  if (previousRoute != null) {
    RouterReportManager.reportCurrentRoute(previousRoute);
  }

  // Here we use a 'inverse didPush set', meaning that we use
  // previous route instead of 'route' because this is
  // a 'inverse push'
  _routeSend?.update((value) {
    // Only PageRoute is allowed to change current value
    if (previousRoute is PageRoute) {
      value.current = _extractRouteName(previousRoute) ?? '';
      value.previous = newRoute.name ?? '';
    } else if (value.previous.isNotEmpty) {
      value.current = value.previous;
    }

    value.args = previousRoute?.settings.arguments;
    value.route = previousRoute;
    value.isBack = true;
    value.removed = '';
    // value.isSnackbar = newRoute.isSnackbar;
    value.isBottomSheet = newRoute.isBottomSheet;
    value.isDialog = newRoute.isDialog;
  });

  // print('currentRoute.isDialog ${currentRoute.isDialog}');

  routing?.call(_routeSend);
}