offAll<T> method

Future<T?>? offAll<T>(
  1. dynamic page, {
  2. RoutePredicate? predicate,
  3. bool opaque = false,
  4. bool? popGesture,
  5. int? id,
  6. String? routeName,
  7. dynamic arguments,
  8. Bindings? binding,
  9. bool fullscreenDialog = false,
  10. Transition? transition,
  11. Curve? curve,
  12. Duration? duration,
  13. double gestureWidth(
    1. BuildContext context
    )?,
})

Push a page and pop several pages in the stack until predicate returns true. predicate is optional

It has the advantage of not needing context, so you can call from your business logic

You can set a custom transition, a curve and a transition duration.

You can send any type of value to the other route in the arguments.

Just like native routing in Flutter, you can push a route as a fullscreenDialog,

predicate can be used like this: Get.until((route) => Get.currentRoute == '/home')so when you get to home page, or also like Get.until((route) => !Get.isDialogOpen()), to make sure the dialog is closed

id is for when you are using nested navigation, as explained in documentation

If you want the same behavior of ios that pops a route when the user drag, you can set popGesture to true

If you're using the Bindings api, you must define it here

By default, GetX will prevent you from push a route that you already in, if you want to push anyway, set preventDuplicates to false

Implementation

Future<T?>? offAll<T>(
  dynamic page, {
  RoutePredicate? predicate,
  bool opaque = false,
  bool? popGesture,
  int? id,
  String? routeName,
  dynamic arguments,
  Bindings? binding,
  bool fullscreenDialog = false,
  Transition? transition,
  Curve? curve,
  Duration? duration,
  double Function(BuildContext context)? gestureWidth,
}) {
  routeName ??= "/${page.runtimeType.toString()}";
  routeName = _cleanRouteName(routeName);
  return global(id).currentState?.pushAndRemoveUntil<T>(
      GetPageRoute<T>(
        opaque: opaque,
        popGesture: popGesture ?? defaultPopGesture,
        page: _resolvePage(page, 'offAll'),
        binding: binding,
        gestureWidth: gestureWidth,
        settings: RouteSettings(
          name: routeName,
          arguments: arguments,
        ),
        fullscreenDialog: fullscreenDialog,
        routeName: routeName,
        transition: transition ?? defaultTransition,
        curve: curve ?? defaultTransitionCurve,
        transitionDuration: duration ?? defaultTransitionDuration,
      ),
      predicate ?? (route) => false);
}