getButtonLabel static method

String getButtonLabel(
  1. BuildContext context,
  2. ContextMenuButtonItem buttonItem
)

Returns the default button label String for the button of the given ContextMenuButtonItem's ContextMenuButtonType.

Implementation

static String getButtonLabel(BuildContext context, ContextMenuButtonItem buttonItem) {
  if (buttonItem.label != null) {
    return buttonItem.label!;
  }

  assert(debugCheckHasCupertinoLocalizations(context));
  final CupertinoLocalizations localizations = CupertinoLocalizations.of(context);
  return switch (buttonItem.type) {
    ContextMenuButtonType.cut       => localizations.cutButtonLabel,
    ContextMenuButtonType.copy      => localizations.copyButtonLabel,
    ContextMenuButtonType.paste     => localizations.pasteButtonLabel,
    ContextMenuButtonType.selectAll => localizations.selectAllButtonLabel,
    ContextMenuButtonType.lookUp    => localizations.lookUpButtonLabel,
    ContextMenuButtonType.searchWeb => localizations.searchWebButtonLabel,
    ContextMenuButtonType.share     => localizations.shareButtonLabel,
    ContextMenuButtonType.liveTextInput
      || ContextMenuButtonType.delete
      || ContextMenuButtonType.custom => '',
  };
}