toAndClearAllNamedRoute method
Navigates to a new route and removes all previous routes from stack.
If a valid BuildContext is provided, this method navigates to the specified named route and removes all previous routes from the navigation stack.
Implementation
void toAndClearAllNamedRoute({String? routeName, Map<String,dynamic>? args}) {
Navigator.pushNamedAndRemoveUntil(context, routeName!, (route) => true,
arguments: args);
}