showPopover static method
void
showPopover({
- required GlobalKey<
State< key,StatefulWidget> > - required BuildContext context,
- required GlobalKey<
State< anchorKey,StatefulWidget> > - CDKDialogPopoverType type = CDKDialogPopoverType.center,
- bool isAnimated = false,
- bool isTranslucent = false,
- Function? onHide,
- required Widget child,
Implementation
static void showPopover({
required GlobalKey key,
required BuildContext context,
required GlobalKey anchorKey,
CDKDialogPopoverType type = CDKDialogPopoverType.center,
bool isAnimated = false,
bool isTranslucent = false,
Function? onHide,
required Widget child,
}) {
if (_activePopoverKeys.containsKey(anchorKey)) {
moveDraggableToTop(context, anchorKey);
return;
}
_activePopoverKeys[anchorKey] = key;
OverlayEntry? overlayEntry;
overlayEntry = OverlayEntry(
builder: (BuildContext context) => CDKDialogPopover(
key: key,
isAnimated: isAnimated,
type: type,
isTranslucent: isTranslucent,
anchorKey: anchorKey,
onHide: () {
onHide?.call();
overlayEntry?.remove();
_activePopoverKeys.remove(anchorKey);
// Close all other popovers
while (_activePopoverKeys.isNotEmpty) {
var refKey = _activePopoverKeys.values.first;
var state = refKey.currentState as CDKDialogPopoverState;
state.hide();
}
},
child: child,
),
);
// Insereix l'OverlayEntry en l'overlay
Overlay.of(context).insert(overlayEntry);
}