close<T extends Object> method

void close<T extends Object>({
  1. bool closeAll = true,
  2. bool closeSnackbar = true,
  3. bool closeDialog = true,
  4. bool closeBottomSheet = true,
  5. String? id,
  6. T? result,
})

Closes specific overlays based on the provided flags.

closeAll determines if all overlays should be closed. closeSnackbar, closeDialog, closeBottomSheet control which specific overlays to close. id is for nested navigation. result is the result passed back when closing the overlays.

Implementation

void close<T extends Object>({
  bool closeAll = true,
  bool closeSnackbar = true,
  bool closeDialog = true,
  bool closeBottomSheet = true,
  String? id,
  T? result,
}) {
  void handleClose(bool closeCondition, Function closeAllFunction,
      Function closeSingleFunction,
      [bool? isOpenCondition]) {
    if (closeCondition) {
      if (closeAll) {
        closeAllFunction();
      } else if (isOpenCondition == true) {
        closeSingleFunction();
      }
    }
  }

  handleClose(closeSnackbar, closeAllSnackbars, closeCurrentSnackbar);
  handleClose(closeDialog, closeAllDialogs, closeOverlay, isDialogOpen);
  handleClose(closeBottomSheet, closeAllBottomSheets, closeOverlay,
      isBottomSheetOpen);
}