offNamedUntil method

  1. @override
Future<T?>? offNamedUntil(
  1. String page, {
  2. bool predicate(
    1. GetPage<T> route
    )?,
  3. Object? arguments,
  4. String? id,
  5. Map<String, String>? parameters,
})
override

Navigates off a named page until a certain condition is met and returns a result of type T.

Implementation

@override
Future<T?>? offNamedUntil(
  String page, {
  bool Function(GetPage<T> route)? predicate,
  Object? arguments,
  String? id,
  Map<String, String>? parameters,
}) async {
  final PageSettings args = _buildPageSettings(page, arguments);
  final RouteDecoder<T>? route = _getRouteDecoder(args);
  if (route == null) {
    return null;
  }

  final bool Function(GetPage<T> route) newPredicate =
      predicate ?? (GetPage<T> route) => false;

  while (_activePages.length > 1 &&
      newPredicate(_activePages.last.route! as GetPage<T>)) {
    _activePages.removeLast();
  }

  return _replaceNamed(route);
}