back method

void back(
  1. {dynamic result,
  2. bool closeOverlays = false,
  3. bool canPop = true,
  4. int id}
)

Navigation.popUntil() shortcut.

Pop the current page, snackbar, dialog or bottomsheet in the stack

if your set closeOverlays to true, Get.back() will close the currently open snackbar/dialog/bottomsheet AND the current page

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

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

Implementation

void back({
  dynamic result,
  bool closeOverlays = false,
  bool canPop = true,
  int id,
}) {
  if (closeOverlays && isOverlaysOpen) {
    navigator?.popUntil((route) {
      return (isOverlaysClosed);
    });
  }
  if (canPop) {
    if (global(id)?.currentState?.canPop() == true) {
      global(id)?.currentState?.pop(result);
    }
  } else {
    global(id)?.currentState?.pop(result);
  }
}