didReplace method

  1. @override
void didReplace({
  1. Route? newRoute,
  2. Route? oldRoute,
})
override

The Navigator replaced oldRoute with newRoute.

Implementation

@override
void didReplace({Route? newRoute, Route? oldRoute}) {
  super.didReplace(newRoute: newRoute, oldRoute: oldRoute);
  final newName = _extractRouteName(newRoute);
  final oldName = _extractRouteName(oldRoute);
  final currentRoute = _RouteData.ofRoute(oldRoute);

  Get.log("REPLACE ROUTE $oldName");
  Get.log("NEW ROUTE $newName");

  if (newRoute != null) {
    RouterReportManager.reportCurrentRoute(newRoute);
  }

  _routeSend?.update((value) {
    // Only PageRoute is allowed to change current value
    if (newRoute is PageRoute) {
      value.current = newName ?? '';
    }

    value.args = newRoute?.settings.arguments;
    value.route = newRoute;
    value.isBack = false;
    value.removed = '';
    value.previous = '$oldName';
    // value.isSnackbar = currentRoute.isSnackbar ? false : value.isSnackbar;
    value.isBottomSheet =
        currentRoute.isBottomSheet ? false : value.isBottomSheet;
    value.isDialog = currentRoute.isDialog ? false : value.isDialog;
  });
  if (oldRoute is GetPageRoute) {
    RouterReportManager.reportRouteWillDispose(oldRoute);
  }

  routing?.call(_routeSend);
}