getx icon indicating copy to clipboard operation
getx copied to clipboard

How to close all overlays?

Open lcsvcn opened this issue 3 years ago • 2 comments

To close all overlays and page we can use:

Get.back(closeOverlays: true);

But in order to close only the overlays (bottom sheet, dialog and snackbar), we can´t use any functions.

I have noticed if I have snackbar and dialog I can´t close both, even using something like this:


  Future<void> closeAllOverlays() async {
    if (Get.isDialogOpen ?? false) {
      Get.back();
    }
    if (Get.isBottomSheetOpen ?? false) {
      Get.back();
    }
    if (Get.isSnackbarOpen) {
      Get.back();
    }
  }

Is there any GET function to close all overlays? I have found closeAllSnackbars() and closeCurrentSnackbar(), but this doesn´t achive closing all overlays.

lcsvcn avatar Oct 06 '22 15:10 lcsvcn

You could now use Get.until((_) => !Get.isOverlaysOpen)

flerovium11 avatar Feb 27 '25 22:02 flerovium11

not working

richanshah avatar Mar 28 '25 07:03 richanshah