addWithPurge method

void addWithPurge(
  1. Widget screen,
  2. Widget purgeTail, {
  3. BaseContainerOptions? options = BaseContainerOptions.defaultSetup,
  4. dynamic arguments,
})

Adds a new screen with a purge similar to replaceUntil It removes the screens upto a particular specified purgeTail

Implementation

void addWithPurge(Widget screen, Widget purgeTail,
    {BaseContainerOptions? options = BaseContainerOptions.defaultSetup,
    dynamic arguments}) {
  List<Widget> screenCache =
      screenViewHistory.sublist(0, screenViewHistory.indexOf(purgeTail) + 1);
  List<BaseContainerOptions> optionsCache =
      optionsHistory.sublist(0, screenViewHistory.indexOf(purgeTail) + 1);
  screenCache.add(screen);
  baseContainerOptions = options!;
  optionsCache.add(baseContainerOptions);
  screenViewHistory = screenCache;
  optionsHistory = optionsCache;
  if (arguments != null) routeArguments = arguments;
  notifyListeners();
}