removeUntilAndPush method
Removes all the previous routes until the predicate
returns true.
id
is used to match listeners.
Process route middlewares before remove.
Implementation
void removeUntilAndPush(
bool Function(PageWrapper pageWrapper) predicate,
String path, {
String? id,
}) {
final routeDefinition = _findRouteDefinition(path);
_processMiddlewares(
routeDefinition,
(RouteDefinition routeDefinition) {
for (var index = _pageStack.length - 1;
index >= 0 && !predicate(_pageStack[index]);
index--) {
_pageStack.removeAt(index);
}
final page =
PageWrapper(routeDefinition, path, _nextRouteIndex, id: id);
_pageStack.add(page);
notifyListeners();
_notifyPush(page);
},
);
}