showOverlay function

void showOverlay(
  1. BuildContext context, {
  2. required GlobalKey<State<StatefulWidget>> key,
  3. bool opaque = false,
  4. required Widget builder(
    1. BuildContext context,
    2. VoidCallback close
    ),
  5. double? width,
  6. double? height,
})

Implementation

void showOverlay(
  BuildContext context, {
  required GlobalKey key,
  bool opaque = false,
  required Widget Function(BuildContext context, VoidCallback close) builder,
  double? width,
  double? height,
}) {
  _overlayEntry = OverlayEntry(
    opaque: opaque,
    builder: (context) => OverlayEntryWidget(
      widgetKey: key,
      width: width,
      height: height,
      builder: (context) {
        return builder(context, _closeOverlay);
      },
      close: _closeOverlay,
    ),
  );

  Overlay.of(context).insert(_overlayEntry!);
}