showDraggable static method
void
showDraggable({
- required GlobalKey<
State< key,StatefulWidget> > - required BuildContext context,
- required GlobalKey<
State< anchorKey,StatefulWidget> > - bool isAnimated = false,
- bool isTranslucent = false,
- Function? onHide,
- required Widget child,
Implementation
static void showDraggable({
required GlobalKey key,
required BuildContext context,
required GlobalKey anchorKey,
bool isAnimated = false,
bool isTranslucent = false,
Function? onHide,
required Widget child,
}) {
if (_activeDraggableKeys.containsKey(anchorKey)) {
moveDraggableToTop(context, anchorKey);
return;
}
_activeDraggableKeys[anchorKey] = key;
OverlayEntry? overlayEntry;
overlayEntry = OverlayEntry(
builder: (BuildContext context) => CDKDialogDraggable(
key: key,
anchorKey: anchorKey,
isAnimated: isAnimated,
isTranslucent: isTranslucent,
onHide: () {
onHide?.call();
overlayEntry?.remove();
_activeDraggableKeys.remove(anchorKey);
},
child: child,
),
);
_activeDraggableEntries[anchorKey] = overlayEntry;
// Insereix l'OverlayEntry en l'overlay
Overlay.of(context).insert(overlayEntry);
}