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 String? newName = _extractRouteName(newRoute);
  final String? oldName = _extractRouteName(oldRoute);
  final _RouteData currentRoute = _RouteData.ofRoute(oldRoute);

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

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

  _routeSend?.update((Routing 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.isBottomSheet =
        currentRoute.isBottomSheet ? false : value.isBottomSheet;
    value.isDialog = currentRoute.isDialog ? false : value.isDialog;
  });

  if (oldRoute is GetPageRoute) {
    RouterReportManager.instance.reportRouteWillDispose(oldRoute);
  }

  routing?.call(_routeSend);
}