toClearAndPushNamed function

void toClearAndPushNamed(
  1. String routeName, {
  2. Map<String, dynamic>? arguments,
})

Clear all existing routes and push a named route onto the navigation stack.

Example:

toClearAndPushNamed('/dashboard');

Implementation

void toClearAndPushNamed(String routeName, {Map<String, dynamic>? arguments}) {
  Navigator.of(Utils.navigatorKey.currentContext!).pushNamedAndRemoveUntil(
    routeName,
    (route) => false,
    arguments: arguments,
  );
}