toAndRemoveUntil method

List<PageSettings> toAndRemoveUntil(
  1. String routeName,
  2. String untilRouteName
)

Add the page with the given routeName and remove all pages until the page with untilRouteName name.

Implementation

List<PageSettings> toAndRemoveUntil(
  String routeName,
  String untilRouteName,
) {
  while (true) {
    if (last.name == untilRouteName) {
      break;
    }
    if (isNotEmpty) {
      removeLast();
    } else {
      break;
    }
  }

  add(PageSettings(name: routeName));
  return this;
}