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}) {
  if (newRoute == null) {
    return;
  }
  if (_goIntercept(newRoute)) {
    navigator?.removeRoute(newRoute);
    return;
  }
  var oldSign = "${(oldRoute?.settings.name ?? "")}#hash#${oldRoute?.hashCode ?? 0}";
  var newSign = "${(newRoute.settings.name ?? "")}#hash#${newRoute.hashCode}";
  if (_routes.contains(oldSign)) {
    var index = _routes.indexOf(oldSign);
    _routeMap.remove(oldSign);
    _routes.insert(index, newSign);
    _routeMap[newSign] = newRoute;
    _routes.remove(oldSign);
  } else {
    _routes.insert(0, newSign);
    _routeMap[newSign] = newRoute;
  }
  _callRouteChange(newRoute, false);
}