toNamedAndOffUntil method

  1. @override
Future<T?> toNamedAndOffUntil(
  1. String page,
  2. bool predicate(
    1. GetPage
    ), [
  3. Object? data
])
override

Navigates to a named page and pops pages until a certain condition is met, returns a result of type T.

Implementation

@override
Future<T?> toNamedAndOffUntil(
  String page,
  bool Function(GetPage) predicate, [
  Object? data,
]) async {
  final PageSettings arguments = _buildPageSettings(page, data);

  final RouteDecoder<T>? route = _getRouteDecoder(arguments);

  if (route == null) {
    return null;
  }

  while (_activePages.isNotEmpty && !predicate(_activePages.last.route!)) {
    _popWithResult();
  }

  return _push(route);
}