show method
- required BuildContext context,
- required WidgetBuilder contextMenuBuilder,
- Widget? debugRequiredFor,
Shows the given context menu.
Since there can only be one shown context menu at a time, calling this will also remove any other context menu that is visible.
Implementation
void show({
required BuildContext context,
required WidgetBuilder contextMenuBuilder,
Widget? debugRequiredFor,
}) {
removeAny();
final OverlayState overlayState = Overlay.of(
context,
rootOverlay: true,
debugRequiredFor: debugRequiredFor,
);
final CapturedThemes capturedThemes = InheritedTheme.capture(
from: context,
to: Navigator.maybeOf(context)?.context,
);
_menuOverlayEntry = OverlayEntry(
builder: (BuildContext context) {
return capturedThemes.wrap(contextMenuBuilder(context));
},
);
overlayState.insert(_menuOverlayEntry!);
_shownInstance = this;
}