void popUntil(BuildContext context, RoutePredicate predicate)

Calls pop repeatedly until the 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 ModalRoute.withName.

Typical usage is as follows:

Navigator.popUntil(context, ModalRoute.withName('/login'));

Source

static void popUntil(BuildContext context, RoutePredicate predicate) {
  Navigator.of(context).popUntil(predicate);
}