pushAndRemoveUntil function

Future pushAndRemoveUntil(
  1. BuildContext context,
  2. Widget widget,
  3. Widget? untilPage, {
  4. bool authCheck = true,
})

you can pass null to untilPage and it will clear the stack

Implementation

Future pushAndRemoveUntil(
  BuildContext context,
  Widget widget,
  Widget? untilPage, {
  bool authCheck = true,
}) {
  return _safeNav(
    context,
    widget,
    () {
      return Navigator.pushAndRemoveUntil(
        context,
        materialRoute(widget),
        (Route<dynamic> route) =>
            route.settings.name == untilPage.runtimeType.toString(),
      );
    },
    authCheck: authCheck,
  );
}