offNamedUntil<T> method

Future<T?>? offNamedUntil<T>(
  1. String page,
  2. bool predicate(
    1. GetPage
    )?, {
  3. String? id,
  4. dynamic arguments,
  5. Map<String, String>? parameters,
})

Navigation.pushNamedAndRemoveUntil() shortcut.

Push the given named page, and then pop several pages in the stack until predicate returns true

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

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

predicate can be used like this: Get.offNamedUntil(page, ModalRoute.withName('/home')) to pop routes in stack until home, or like this: Get.offNamedUntil((route) => !Get.isDialogOpen()), to make sure the dialog is closed

Note: Always put a slash on the route name ('/page1'), to avoid unexpected errors

Implementation

Future<T?>? offNamedUntil<T>(
  String page,
  bool Function(GetPage<dynamic>)? predicate, {
  String? id,
  dynamic arguments,
  Map<String, String>? parameters,
}) {
  if (parameters != null) {
    final Uri uri = Uri(path: page, queryParameters: parameters);
    page = uri.toString();
  }

  return searchDelegate(id).offNamedUntil<T>(
    page,
    predicate: predicate,
    id: id,
    arguments: arguments,
    parameters: parameters,
  );
}