pushAndPopUntil<T extends Object?> method

  1. @optionalTypeArgs
Future<T?> pushAndPopUntil<T extends Object?>(
  1. PageRouteInfo route, {
  2. required RoutePredicate predicate,
  3. bool scopedPopUntil = true,
  4. OnNavigationFailure? onFailure,
})

Push the given route onto the navigator, and then maybePop all the previous routes until the predicate returns true.

if onFailure callback is provided, navigation errors will be passed to it otherwise they'll be thrown

Implementation

@optionalTypeArgs
Future<T?> pushAndPopUntil<T extends Object?>(
  PageRouteInfo route, {
  required RoutePredicate predicate,
  bool scopedPopUntil = true,
  OnNavigationFailure? onFailure,
}) {
  if (!scopedPopUntil) {
    popUntil(predicate, scoped: false);
  }
  final scope = _findStackScope(route);
  if (scopedPopUntil) {
    scope.popUntil(predicate);
  }
  return scope._push<T>(route, onFailure: onFailure);
}