showModal static method

void showModal({
  1. required GlobalKey<State<StatefulWidget>> key,
  2. required BuildContext context,
  3. bool isAnimated = false,
  4. bool isTranslucent = false,
  5. Function? onHide,
  6. required Widget child,
})

Implementation

static void showModal({
  required GlobalKey key,
  required BuildContext context,
  bool isAnimated = false,
  bool isTranslucent = false,
  Function? onHide,
  required Widget child,
}) {
  if (_activeModalKey is CDKDialogModalState) {
    var refKey = _activeModalKey as GlobalKey<CDKDialogModalState>;
    refKey.currentState?.hide();
  }
  _activeModalKey = key;

  OverlayEntry? overlayEntry;
  overlayEntry = OverlayEntry(
    builder: (BuildContext context) => CDKDialogModal(
      key: key,
      isAnimated: isAnimated,
      isTranslucent: isTranslucent,
      onHide: () {
        onHide?.call();
        overlayEntry?.remove();
        _activeModalKey = null;
      },
      child: child,
    ),
  );

  // Insereix l'OverlayEntry en l'overlay
  Overlay.of(context).insert(overlayEntry);
}