toPushNamedAndClearUntil function

void toPushNamedAndClearUntil(
  1. String routeName,
  2. RoutePredicate predicate, {
  3. Map<String, dynamic>? arguments,
})

Push a named route onto the navigation stack and remove routes until a specified predicate is met.

Example:

toPushNamedAndClearUntil('/login', ModalRoute.withName('/dashboard'));

Implementation

void toPushNamedAndClearUntil(String routeName, RoutePredicate predicate,
    {Map<String, dynamic>? arguments}) {
  Navigator.of(Utils.navigatorKey.currentContext!).pushNamedAndRemoveUntil(
    routeName,
    predicate,
    arguments: arguments,
  );
}