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