show method

Future<void> show({
  1. required BuildContext context,
  2. required WidgetBuilder builder,
  3. Widget? debugRequiredFor,
  4. OverlayEntry? below,
})

Displays the magnifier.

Returns a future that completes when the magnifier is fully shown, i.e. done with its entry animation.

To control what overlays are shown in the magnifier, use below. See overlayEntry for more details on how to utilize below.

If the magnifier already exists (i.e. overlayEntry != null), then show will replace the old overlay without playing an exit animation. Consider awaiting hide first, to animate from the old magnifier to the new one.

Implementation

Future<void> show({
  required BuildContext context,
  required WidgetBuilder builder,
  Widget? debugRequiredFor,
  OverlayEntry? below,
}) async {
  _overlayEntry?.remove();
  _overlayEntry?.dispose();

  final OverlayState overlayState = Overlay.of(
    context,
    rootOverlay: true,
    debugRequiredFor: debugRequiredFor,
  );

  final CapturedThemes capturedThemes = InheritedTheme.capture(
    from: context,
    to: Navigator.maybeOf(context)?.context,
  );

  _overlayEntry = OverlayEntry(
    builder: (BuildContext context) => capturedThemes.wrap(builder(context)),
  );
  overlayState.insert(overlayEntry!, below: below);

  if (animationController != null) {
    await animationController?.forward();
  }
}