showMenu<T> function
Future<T?>
showMenu<T>({
- required BuildContext context,
- required List<
ContextMenuEntry< items,T> > - required Rect position,
- double? width,
- String? semanticLabel,
- String? barrierLabel,
- T? initialValue,
- ContextMenuThemeData? contextMenuThemeData,
Shows a menu given a relative position for the target.
Implementation
Future<T?> showMenu<T>({
required BuildContext context,
required List<ContextMenuEntry<T>> items,
required Rect position,
double? width,
String? semanticLabel,
String? barrierLabel,
T? initialValue,
ContextMenuThemeData? contextMenuThemeData,
}) {
assert(items.isNotEmpty);
final controller = _ContextController<T>._(
value: initialValue,
width: width,
items: items,
position: position,
contextMenuThemeData: contextMenuThemeData,
);
return Navigator.of(context, rootNavigator: true).push<T>(
_ContextMenuRoute(
pageBuilder: (context, animation, secondaryAnimation) => _ContextScope<T>(
controller,
child: CustomSingleChildLayout(
delegate: ContextMenuLayoutDelegate(position),
child: SizedBox(
width: width,
child: GestureDetector(
behavior: HitTestBehavior.deferToChild,
onTap: () {},
child: contextMenuThemeData != null
? ContextMenuTheme(
data: contextMenuThemeData,
child: _ContextMenu<T>(semanticLabel: semanticLabel),
)
: _ContextMenu<T>(semanticLabel: semanticLabel),
),
),
),
),
),
);
// Overlay.of(context, rootOverlay: true).insert(controller._overlayEntry);
// return controller._completer.future;
}