diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 9f857021fdf..b8effd5a2fa 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -1255,11 +1255,14 @@ class EditableText extends StatefulWidget { final Color? selectionColor; /// {@template flutter.widgets.editableText.selectionControls} - /// Optional delegate for building the text selection handles and toolbar. + /// Optional delegate for building the text selection handles. /// - /// The [EditableText] widget used on its own will not trigger the display - /// of the selection toolbar by itself. The toolbar is shown by calling - /// [EditableTextState.showToolbar] in response to an appropriate user event. + /// Historically, this field also controlled the toolbar. This is now handled + /// by [contextMenuBuilder] instead. However, for backwards compatibility, when + /// [selectionControls] is set to an object that does not mix in + /// [TextSelectionHandleControls], [contextMenuBuilder] is ignored and the + /// [TextSelectionControls.buildToolbar] method is used instead. + /// {@endtemplate} /// /// See also: /// @@ -1269,7 +1272,6 @@ class EditableText extends StatefulWidget { /// * [TextField], a Material Design themed wrapper of [EditableText], which /// shows the selection toolbar upon appropriate user events based on the /// user's platform set in [ThemeData.platform]. - /// {@endtemplate} final TextSelectionControls? selectionControls; /// {@template flutter.widgets.editableText.keyboardType} @@ -1778,6 +1780,11 @@ class EditableText extends StatefulWidget { /// `buttonItems` represents the buttons that would be built by default for /// this widget. /// + /// For backwards compatibility, when [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. diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index 8d459217275..177c32f7c63 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -61,23 +61,28 @@ class ToolbarItemsParentData extends ContainerBoxParentData { /// An interface for building the selection UI, to be provided by the /// implementer of the toolbar widget. /// -/// Override text operations such as [handleCut] if needed. +/// Parts of this class, including [buildToolbar], have been deprecated in favor +/// of [EditableText.contextMenuBuilder], which is now the preferred way to +/// customize the context menus. /// /// ## Use with [EditableText.contextMenuBuilder] -/// [buildToolbar] has been deprecated in favor of -/// [EditableText.contextMenuBuilder], and that is the preferred way to -/// customize the context menus now. However, both ways will continue to work -/// during the deprecation period. /// -/// To use both [EditableText.contextMenuBuilder] and [buildHandle], a two-step -/// migration is necessary. First, migrate to [TextSelectionHandleControls], -/// using its [TextSelectionHandleControls.buildHandle] method and moving -/// toolbar code to [EditableText.contextMenuBuilder]. Later, the deprecation -/// period will expire, [buildToolbar] will be removed, and -/// [TextSelectionHandleControls] will be deprecated. Migrate back to -/// [TextSelectionControls.buildHandle], so that the final state is to use -/// [EditableText.contextMenuBuilder] for the toolbar and -/// [TextSelectionControls] for the handles. +/// For backwards compatibility during the deprecation period, when +/// [EditableText.selectionControls] is set to an object that does not mix in +/// [TextSelectionHandleControls], [EditableText.contextMenuBuilder] is ignored +/// in favor of the deprecated [buildToolbar]. +/// +/// To migrate code from [buildToolbar] to the preferred +/// [EditableText.contextMenuBuilder], while still using [buildHandle], mix in +/// [TextSelectionHandleControls] into the [TextSelectionControls] subclass when +/// moving any toolbar code to a callback passed to +/// [EditableText.contextMenuBuilder]. +/// +/// In due course, [buildToolbar] will be removed, and the mixin will no longer +/// be necessary as a way to flag to the framework that the code has been +/// migrated and does not expect [buildToolbar] to be called. +/// +/// For more information, see . /// /// See also: ///