render method

OverlayEntry render(
  1. BuildContext context, {
  2. ValueChanged<TapDownDetails>? onClose,
  3. required Offset position,
  4. required WidgetBuilder popupBuilder,
})

Render overlay entry on the screen with dismiss logic

Implementation

OverlayEntry render(
  BuildContext context, {
  ValueChanged<TapDownDetails>? onClose,
  required Offset position,
  required WidgetBuilder popupBuilder,
}) {
  final _createdEntry = OverlayEntry(
    builder: (context) => GestureDetector(
      behavior: HitTestBehavior.opaque,
      onTapDown: onClose,
      child: Material(
        color: Colors.transparent,
        type: MaterialType.canvas,
        child: Stack(
          children: [
            CustomSingleChildLayout(
              delegate: PopupOverlayLayoutDelegate(position),
              child: TapRegion(
                onTapOutside: (_) => dismiss(),
                child: popupBuilder(context),
              ),
            ),
          ],
        ),
      ),
    ),
  );

  Overlay.of(context).insert(_createdEntry);
  _overlayEntry = _createdEntry;

  return _createdEntry;
}