toClearAndPush function
Clear all existing routes and push the provided page onto the navigation stack, optionally with custom settings.
Example:
toClearAndPush(MyHomePage(), settings: RouteSettings(name: '/home'));
Implementation
void toClearAndPush(Widget page, {RouteSettings? settings}) {
Navigator.of(Utils.navigatorKey.currentContext!).pushAndRemoveUntil(
MaterialPageRoute(builder: (context) => page, settings: settings),
(route) => false,
);
}