replaceRouteBelow< T extends Object> method
- @optionalTypeArgs
Replaces a route on the navigator with a new route. The route to be
replaced is the one below the given anchorRoute
.
The old route must not be current visible, as this method skips the animations and therefore the removal would be jarring if it was visible. To replace the top-most route, consider pushReplacement instead, which does animate the new route, and delays removing the old route until the new route has finished animating.
The removed route is removed without being completed, so this method does not take a return value argument.
The new route, the route below the new route (if any), and the route above
the new route, are all notified (see Route.didReplace,
Route.didChangeNext, and Route.didChangePrevious). If the Navigator
has any Navigator.observers, they will be notified as well (see
NavigatorObservers.didReplace
). The removed route is disposed without
being notified. The future that had been returned from pushing that routes
will not complete.
The T
type argument is the type of the return value of the new route.
See also:
- replace, which is the same but identifies the route to be removed directly.
Implementation
@optionalTypeArgs
void replaceRouteBelow<T extends Object>({ @required Route<dynamic> anchorRoute, Route<T> newRoute }) {
assert(anchorRoute != null);
assert(anchorRoute._navigator == this);
assert(_history.indexOf(anchorRoute) > 0);
replace<T>(oldRoute: _history[_history.indexOf(anchorRoute) - 1], newRoute: newRoute);
}