off<T> method

Future<T> off<T>(
  1. Widget page,
  2. {bool opaque = false,
  3. Transition transition,
  4. Curve curve,
  5. bool popGesture,
  6. int id,
  7. dynamic arguments,
  8. Bindings binding,
  9. bool fullscreenDialog = false,
  10. bool preventDuplicates = true,
  11. Duration duration}
)

Navigation.pushReplacement() shortcut .

Pop the current page and pushes a new page to the stack

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

You can set a custom transition, define a Tween 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,

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> off<T>(
  Widget page, {
  bool opaque = false,
  Transition transition,
  Curve curve,
  bool popGesture,
  int id,
  dynamic arguments,
  Bindings binding,
  bool fullscreenDialog = false,
  bool preventDuplicates = true,
  Duration duration,
}) {
  var routeName = "/${page.runtimeType.toString()}";
  if (preventDuplicates && routeName == currentRoute) {
    return null;
  }
  return global(id)?.currentState?.pushReplacement(GetPageRoute(
      opaque: opaque ?? true,
      page: () => page,
      binding: binding,
      settings: RouteSettings(arguments: arguments),
      routeName: routeName,
      fullscreenDialog: fullscreenDialog,
      popGesture: popGesture ?? defaultPopGesture,
      transition: transition ?? defaultTransition,
      curve: curve ?? defaultTransitionCurve,
      transitionDuration: duration ?? defaultTransitionDuration));
}