Problem
CodeField does not expose a way to customize the text selection context menu
(copy / select all / custom actions), unlike Flutter's TextField and
EditableText, which provide contextMenuBuilder.
This makes it impossible to:
- Customize the selection toolbar
- Add app-specific actions (Search, Format, Go to line, etc.)
- Match platform behavior or design requirements
What works in TextField
TextField(
contextMenuBuilder: (context, editableTextState) {
return AdaptiveTextSelectionToolbar(
anchors: editableTextState.contextMenuAnchors,
children: const [
SelectionOptions(),
],
);
},
)
Current CodeField API
CodeField(
controller: _codeController,
textStyle: const TextStyle(fontFamily: 'monospace'),
)
There is currently no way to pass a contextMenuBuilder or otherwise customize
the selection toolbar.
Request / Proposal
Expose a contextMenuBuilder (or equivalent) on CodeField, and forward it
internally to the underlying EditableText.
Example API:
CodeField(
controller: _codeController,
contextMenuBuilder: (context, editableTextState) {
return AdaptiveTextSelectionToolbar(
anchors: editableTextState.contextMenuAnchors,
children: const [
SelectionOptions(),
],
);
},
)
Problem
CodeFielddoes not expose a way to customize the text selection context menu(copy / select all / custom actions), unlike Flutter's
TextFieldandEditableText, which providecontextMenuBuilder.This makes it impossible to:
What works in TextField
Current CodeField API
There is currently no way to pass a contextMenuBuilder or otherwise customize
the selection toolbar.
Request / Proposal
Expose a contextMenuBuilder (or equivalent) on CodeField, and forward it
internally to the underlying EditableText.
Example API: