offAllNamed<T> method

Future<T?>? offAllNamed<T>(
  1. String newRouteName, {
  2. dynamic arguments,
  3. String? id,
  4. Map<String, String>? parameters,
})

Navigation.pushNamedAndRemoveUntil() shortcut.

Push a named 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 send any type of value to the other route in the arguments.

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

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

Implementation

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

  return searchDelegate(id).offAllNamed<T>(
    newRouteName,
    //predicate: predicate ?? (_) => false,
    arguments: arguments,
    id: id,
    parameters: parameters,
  );
}