popUntil method
Calls pop repeatedly until predicate returns true for the current route.
Implementation
void popUntil(RoutePredicate predicate, [Object? result]) {
setState(() {
while (_history.length > 1 && !predicate(_history.last)) {
_removeLast(result);
}
});
}