popUntil<T extends Widget> method

void popUntil<T extends Widget>([
  1. Object? result
])

Pops all routes until the page of type T is visible. The page must have been pushed with push before so the route name matches the widget type. If no route of type T is in the stack, all routes except the first one are popped.

Implementation

void popUntil<T extends Widget>([Object? result]) {
  assert(T != Widget, 'Provide a page type: popUntil<MyPage>()');
  _key.currentState?.popUntilWithResult(
    (route) => route.settings.name == T.toString() || route.isFirst,
    result,
  );
}