toPushAndClearAll function
Push the provided page onto the navigation stack and remove all routes until a specified predicate is met.
Example:
toPushAndClearAll(MyPage(), settings: RouteSettings(name: '/newPage'));
Implementation
void toPushAndClearAll(Widget page, {RouteSettings? settings}) {
Navigator.of(Utils.navigatorKey.currentContext!).pushAndRemoveUntil(
MaterialPageRoute(
settings: settings,
builder: (context) => page,
),
(route) => false,
);
}