overlayEntry property

OverlayEntry? overlayEntry

The magnifier's OverlayEntry, if currently in the overlay.

This is exposed so that other overlay entries can be positioned above or below this overlayEntry. Anything in the paint order after the RawMagnifier in this OverlayEntry will not be displayed in the magnifier; if it is desired for an overlay entry to be displayed in the magnifier, it must be positioned below the magnifier.

link
void magnifierShowExample(BuildContext context) {
  final MagnifierController myMagnifierController = MagnifierController();

  // Placed below the magnifier, so it will show.
  Overlay.of(context).insert(OverlayEntry(
      builder: (BuildContext context) => const Text('I WILL display in the magnifier')));

  // Will display in the magnifier, since this entry was passed to show.
  final OverlayEntry displayInMagnifier = OverlayEntry(
      builder: (BuildContext context) =>
          const Text('I WILL display in the magnifier'));

  Overlay.of(context)
      .insert(displayInMagnifier);
  myMagnifierController.show(
      context: context,
      below: displayInMagnifier,
      builder: (BuildContext context) => const RawMagnifier(
            size: Size(100, 100),
          ));

  // By default, new entries will be placed over the top entry.
  Overlay.of(context).insert(OverlayEntry(
      builder: (BuildContext context) => const Text('I WILL NOT display in the magnifier')));

  Overlay.of(context).insert(
      below:
          myMagnifierController.overlayEntry, // Explicitly placed below the magnifier.
      OverlayEntry(
          builder: (BuildContext context) => const Text('I WILL display in the magnifier')));
}

To check if a magnifier is in the overlay, use shown. The overlayEntry field may be non-null even when the magnifier is not visible.

Implementation

OverlayEntry? get overlayEntry => _overlayEntry;