buttonItemsForToolbarOptions method

  1. @Deprecated('Use `contextMenuBuilder` instead of `toolbarOptions`. ' 'This feature was deprecated after v3.3.0-0.5.pre.')
List<ContextMenuButtonItem>? buttonItemsForToolbarOptions([
  1. TargetPlatform? targetPlatform
])

Returns the ContextMenuButtonItems for the given ToolbarOptions.

Implementation

@Deprecated(
  'Use `contextMenuBuilder` instead of `toolbarOptions`. '
  'This feature was deprecated after v3.3.0-0.5.pre.',
)
List<ContextMenuButtonItem>? buttonItemsForToolbarOptions([TargetPlatform? targetPlatform]) {
  final ToolbarOptions toolbarOptions = widget.toolbarOptions;
  if (toolbarOptions == ToolbarOptions.empty) {
    return null;
  }
  return <ContextMenuButtonItem>[
    if (toolbarOptions.cut && cutEnabled)
      ContextMenuButtonItem(
        onPressed: () {
          cutSelection(SelectionChangedCause.toolbar);
        },
        type: ContextMenuButtonType.cut,
      ),
    if (toolbarOptions.copy && copyEnabled)
      ContextMenuButtonItem(
        onPressed: () {
          copySelection(SelectionChangedCause.toolbar);
        },
        type: ContextMenuButtonType.copy,
      ),
    if (toolbarOptions.paste && pasteEnabled)
      ContextMenuButtonItem(
        onPressed: () {
          pasteText(SelectionChangedCause.toolbar);
        },
        type: ContextMenuButtonType.paste,
      ),
    if (toolbarOptions.selectAll && selectAllEnabled)
      ContextMenuButtonItem(
        onPressed: () {
          selectAll(SelectionChangedCause.toolbar);
        },
        type: ContextMenuButtonType.selectAll,
      ),
  ];
}