getSelectableButtonItems static method

List<ContextMenuButtonItem> getSelectableButtonItems(
  1. {required SelectionGeometry selectionGeometry,
  2. required VoidCallback onCopy,
  3. required VoidCallback onSelectAll}

Returns the ContextMenuButtonItems representing the buttons in this platform's default selection menu.

For example, SelectableRegion uses this to generate the default buttons for its context menu.

See also:


static List<ContextMenuButtonItem> getSelectableButtonItems({
  required final SelectionGeometry selectionGeometry,
  required final VoidCallback onCopy,
  required final VoidCallback onSelectAll,
}) {
  final bool canCopy = selectionGeometry.status == SelectionStatus.uncollapsed;
  final bool canSelectAll = selectionGeometry.hasContent;

  // Determine which buttons will appear so that the order and total number is
  // known. A button's position in the menu can slightly affect its
  // appearance.
  return <ContextMenuButtonItem>[
    if (canCopy)
        onPressed: onCopy,
        type: ContextMenuButtonType.copy,
    if (canSelectAll)
        onPressed: onSelectAll,
        type: ContextMenuButtonType.selectAll,