contextMenuBuilder property
Whether iOS 14 Scribble features are enabled for this widget.
Only available on iPads.
Defaults to true. Whether to enable that the IME update personalized data such as typing history and user dictionary data.
This flag only affects Android. On iOS, there is no equivalent flag.
Defaults to true.
See also:
- developer.android.com/reference/android/view/inputmethod/EditorInfo#IME_FLAG_NO_PERSONALIZED_LEARNING Configuration of handler for media content inserted via the system input method.
Defaults to null in which case media content insertion will be disabled, and the system will display a message informing the user that the text field does not support inserting media content.
Set ContentInsertionConfiguration.onContentInserted to provide a handler. Additionally, set ContentInsertionConfiguration.allowedMimeTypes to limit the allowable mime types for inserted content.
{@tool dartpad}
This example shows how to access the data for inserted content in your
TextField.
** See code in examples/api/lib/widgets/editable_text/editable_text.on_content_inserted.0.dart ** {@end-tool}
If contentInsertionConfiguration is not provided, by default
an empty list of mime types will be sent to the Flutter Engine.
A handler function must be provided in order to customize the allowable
mime types for inserted content.
If rich content is inserted without a handler, the system will display a message informing the user that the current text input does not support inserting rich content. Builds the text selection toolbar when requested by the user.
The context menu is built when EditableTextState.showToolbar is called, typically by one of the callbacks installed by the widget created by TextSelectionGestureDetectorBuilder.buildGestureDetector. The widget returned by contextMenuBuilder is passed to a ContextMenuController.
If no callback is provided, no context menu will be shown.
The EditableTextContextMenuBuilder signature used by the contextMenuBuilder callback has two parameters, the BuildContext of the EditableText and the EditableTextState of the EditableText.
The EditableTextState has two properties that are especially useful when building the widgets for the context menu:
-
EditableTextState.contextMenuAnchors specifies the desired anchor position for the context menu.
-
EditableTextState.contextMenuButtonItems represents the buttons that should typically be built for this widget (e.g. cut, copy, paste).
The TextSelectionToolbarLayoutDelegate class may be particularly useful in honoring the preferred anchor positions.
For backwards compatibility, when EditableText.selectionControls is set to an object that does not mix in TextSelectionHandleControls, contextMenuBuilder is ignored and the TextSelectionControls.buildToolbar method is used instead.
{@tool dartpad} This example shows how to customize the menu, in this case by keeping the default buttons for the platform but modifying their appearance.
** See code in examples/api/lib/material/context_menu/editable_text_toolbar_builder.0.dart ** {@end-tool}
{@tool dartpad} This example shows how to show a custom button only when an email address is currently selected.
** See code in examples/api/lib/material/context_menu/editable_text_toolbar_builder.1.dart ** {@end-tool}
See also:
- AdaptiveTextSelectionToolbar, which builds the default text selection toolbar for the current platform, but allows customization of the buttons.
- AdaptiveTextSelectionToolbar.getAdaptiveButtons, which builds the button Widgets for the current platform given ContextMenuButtonItems.
- BrowserContextMenu, which allows the browser's context menu on web to be disabled and Flutter-rendered context menus to appear.
If not provided, will build a default menu based on the platform.
See also:
- AdaptiveTextSelectionToolbar, which is built by default.
Implementation
// final bool scribbleEnabled;
/// {@macro flutter.services.TextInputConfiguration.enableIMEPersonalizedLearning}
// final bool enableIMEPersonalizedLearning;
/// {@macro flutter.widgets.editableText.contentInsertionConfiguration}
// final ContentInsertionConfiguration? contentInsertionConfiguration;
/// {@macro flutter.widgets.EditableText.contextMenuBuilder}
///
/// If not provided, will build a default menu based on the platform.
///
/// See also:
///
/// * [AdaptiveTextSelectionToolbar], which is built by default.
final EditableTextContextMenuBuilder? contextMenuBuilder;