popToView method

void popToView(
  1. String routeIdentifier, [
  2. NavigationContext? navigationContext
])

Implementation

void popToView(String routeIdentifier, [NavigationContext? navigationContext]) {
  _poppedNavigationContext = navigationContext;

  if (!_history.map((h) => h.routeName).contains(routeIdentifier)) {
    return beagle.logger
        .error("Cannot pop to \"$routeIdentifier\" because it doesn't exist in the navigation history.");
  }
  _thisNavigatorKey.currentState!.popUntil((route) => route.settings.name == routeIdentifier);
  while (_history.last.routeName != routeIdentifier) {
    _history.removeLast();
  }

  if (_history.isNotEmpty) {
    /* It has already popped at this time */
    setNavigationContext(navigationContext);
    _poppedNavigationContext = null;
  }
}