showModal static method
void
showModal({
- required GlobalKey<
State< key,StatefulWidget> > - required BuildContext context,
- bool isAnimated = false,
- bool isTranslucent = false,
- Function? onHide,
- 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);
}