removeRouteBelow method

void removeRouteBelow (Route anchorRoute)

Immediately remove a route from the navigator, and Route.dispose it. The route to be replaced is the one below the given anchorRoute.

The removed route is removed without being completed, so this method does not take a return value argument. No animations are run as a result of this method call.

The routes below and above the removed route are notified (see Route.didChangeNext and Route.didChangePrevious). If the Navigator has any Navigator.observers, they will be notified as well (see NavigatorObserver.didRemove). The removed route is disposed without being notified. The future that had been returned from pushing that routes will not complete.

The given anchorRoute must be in the history and must have a route below it; this method will throw an exception if it is not or does not.

Ongoing gestures within the current route are canceled.


void removeRouteBelow(Route<dynamic> anchorRoute) {
  assert(() { _debugLocked = true; return true; }());
  assert(anchorRoute._navigator == this);
  final int index = _history.indexOf(anchorRoute) - 1;
  assert(index >= 0);
  final Route<dynamic> targetRoute = _history[index];
  assert(targetRoute._navigator == this);
  assert(targetRoute.overlayEntries.isEmpty || !overlay.debugIsVisible(targetRoute.overlayEntries.last));
  final Route<dynamic> nextRoute = index < _history.length ? _history[index] : null;
  final Route<dynamic> previousRoute = index > 0 ? _history[index - 1] : null;
  if (previousRoute != null)
  if (nextRoute != null)
  assert(() { _debugLocked = false; return true; }());