show static method
void
show({})
Implementation
static void show({
required BuildContext context,
required String dialogId,
required Widget dialog,
bool barrierDismissible = true,
Color barrierColor = Colors.black54,
bool rootOverlay = true,
bool enableHide = false,
}) {
dismiss(dialogId);
final overlay = Overlay.of(context, rootOverlay: rootOverlay);
late OverlayEntry overlayEntry;
final WidgetBuilder widgetBuilder = (builderContext) {
return Stack(
children: [
Positioned.fill(
child: GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: barrierDismissible ? () => dismiss(dialogId) : null,
child: Container(
color: barrierColor,
),
),
),
Center(
child: Material(
color: Colors.transparent,
child: dialog,
),
),
],
);
};
ValueNotifier<bool> isVisable = ValueNotifier(true);
if (enableHide) {
overlayEntry = OverlayEntry(
builder: (context) {
return ValueListenableBuilder<bool>(
valueListenable: isVisable,
builder: (_, visible, __) {
return Offstage(
offstage: !visible,
child: widgetBuilder.call(context),
);
},
);
},
);
} else {
overlayEntry = OverlayEntry(
builder: (context) => widgetBuilder.call(context),
);
}
overlay.insert(overlayEntry);
_overlays[dialogId] = OverlayEntryWrapper(overlayEntry: overlayEntry, isVisable: isVisable);
}