popModeUntil method

  1. @override
Future<void> popModeUntil(
  1. String fullRoute, {
  2. PopMode popMode = PopMode.history,
})
override

Removes routes according to PopMode until it reaches the specific fullRoute, DOES NOT remove the fullRoute

Implementation

@override
Future<void> popModeUntil(
  String fullRoute, {
  PopMode popMode = PopMode.history,
}) async {
  // remove history or page entries until you meet route
  RouteDecoder<T>? iterator = currentConfiguration;
  while (_canPop(popMode) && iterator != null) {
    //the next line causes wasm compile error if included in the while loop
    //https://github.com/flutter/flutter/issues/140110
    if (iterator.pageSettings?.name == fullRoute) {
      break;
    }
    await _pop(popMode, null);
    // replace iterator
    iterator = currentConfiguration;
  }
  notifyListeners();
}