getContextMenuBuilder method
Implementation
EditableTextContextMenuBuilder? getContextMenuBuilder(Map? spec) {
if (spec == null || spec.isEmpty) {
return null;
}
return (context, editableTextState) {
final List<ContextMenuButtonItem> buttonItems =
editableTextState.contextMenuButtonItems;
if (!parseBool(spec["copy"], defaultValue: true)) {
buttonItems.removeWhere((ContextMenuButtonItem buttonItem) =>
buttonItem.type == ContextMenuButtonType.copy);
}
if (!parseBool(spec["cut"], defaultValue: true)) {
buttonItems.removeWhere((ContextMenuButtonItem buttonItem) =>
buttonItem.type == ContextMenuButtonType.cut);
}
if (!parseBool(spec["paste"], defaultValue: true)) {
buttonItems.removeWhere((ContextMenuButtonItem buttonItem) =>
buttonItem.type == ContextMenuButtonType.paste);
}
if (!parseBool(spec["delete"], defaultValue: true)) {
buttonItems.removeWhere((ContextMenuButtonItem buttonItem) =>
buttonItem.type == ContextMenuButtonType.delete);
}
if (!parseBool(spec["selectAll"], defaultValue: true)) {
buttonItems.removeWhere((ContextMenuButtonItem buttonItem) =>
buttonItem.type == ContextMenuButtonType.selectAll);
}
if (!parseBool(spec["liveTextInput"], defaultValue: true)) {
buttonItems.removeWhere((ContextMenuButtonItem buttonItem) =>
buttonItem.type == ContextMenuButtonType.liveTextInput);
}
return AdaptiveTextSelectionToolbar.buttonItems(
anchors: editableTextState.contextMenuAnchors,
buttonItems: buttonItems,
);
};
}