void popUntil(RoutePredicate predicate)

Repeatedly calls pop until the given predicate returns true.

The predicate may be applied to the same route more than once if Route.willHandlePopInternally is true.

To pop until a route with a certain name, use the RoutePredicate returned from withName.

Source

void popUntil(RoutePredicate predicate) {
  while (!predicate(_history.last))
    pop();
}