showMenu<T> function

Future<T?> showMenu<T>({
  1. required BuildContext context,
  2. required RelativeRect position,
  3. required List<PopupMenuEntry<T>> items,
  4. T? initialValue,
  5. double? elevation,
  6. String? semanticLabel,
  7. ShapeBorder? shape,
  8. Color? color,
  9. bool useRootNavigator = false,
  10. Style? menuStyle,
  11. required Duration duration,
  12. required Curve curve,
})

Implementation

Future<T?> showMenu<T>({
  required BuildContext context,
  required RelativeRect position,
  required List<PopupMenuEntry<T>> items,
  T? initialValue,
  double? elevation,
  String? semanticLabel,
  ShapeBorder? shape,
  Color? color,
  bool useRootNavigator = false,
  Style? menuStyle,
  required Duration duration,
  required Curve curve,
}) {
  assert(items.isNotEmpty);
  assert(debugCheckHasMaterialLocalizations(context));

  switch (Theme.of(context).platform) {
    case TargetPlatform.iOS:
    case TargetPlatform.macOS:
      break;
    case TargetPlatform.android:
    case TargetPlatform.fuchsia:
    case TargetPlatform.linux:
    case TargetPlatform.windows:
      semanticLabel ??= MaterialLocalizations.of(context).popupMenuLabel;
  }

  final NavigatorState navigator =
      Navigator.of(context, rootNavigator: useRootNavigator);
  return navigator.push(_PopupMenuRoute<T>(
    position: position,
    items: items,
    initialValue: initialValue,
    semanticLabel: semanticLabel,
    barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel,
    capturedThemes:
        InheritedTheme.capture(from: context, to: navigator.context),
    menuStyle: menuStyle,
    duration: duration,
    curve: curve,
  ));
}