Further clarification of the TextSelectionControls migration (#132539)
Further follow-up for https://github.com/flutter/flutter/issues/122421.
This commit is contained in:
parent
efdfd96c4a
commit
cc0d63ea66
@ -1255,11 +1255,14 @@ class EditableText extends StatefulWidget {
|
|||||||
final Color? selectionColor;
|
final Color? selectionColor;
|
||||||
|
|
||||||
/// {@template flutter.widgets.editableText.selectionControls}
|
/// {@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
|
/// Historically, this field also controlled the toolbar. This is now handled
|
||||||
/// of the selection toolbar by itself. The toolbar is shown by calling
|
/// by [contextMenuBuilder] instead. However, for backwards compatibility, when
|
||||||
/// [EditableTextState.showToolbar] in response to an appropriate user event.
|
/// [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:
|
/// See also:
|
||||||
///
|
///
|
||||||
@ -1269,7 +1272,6 @@ class EditableText extends StatefulWidget {
|
|||||||
/// * [TextField], a Material Design themed wrapper of [EditableText], which
|
/// * [TextField], a Material Design themed wrapper of [EditableText], which
|
||||||
/// shows the selection toolbar upon appropriate user events based on the
|
/// shows the selection toolbar upon appropriate user events based on the
|
||||||
/// user's platform set in [ThemeData.platform].
|
/// user's platform set in [ThemeData.platform].
|
||||||
/// {@endtemplate}
|
|
||||||
final TextSelectionControls? selectionControls;
|
final TextSelectionControls? selectionControls;
|
||||||
|
|
||||||
/// {@template flutter.widgets.editableText.keyboardType}
|
/// {@template flutter.widgets.editableText.keyboardType}
|
||||||
@ -1778,6 +1780,11 @@ class EditableText extends StatefulWidget {
|
|||||||
/// `buttonItems` represents the buttons that would be built by default for
|
/// `buttonItems` represents the buttons that would be built by default for
|
||||||
/// this widget.
|
/// 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}
|
/// {@tool dartpad}
|
||||||
/// This example shows how to customize the menu, in this case by keeping the
|
/// This example shows how to customize the menu, in this case by keeping the
|
||||||
/// default buttons for the platform but modifying their appearance.
|
/// default buttons for the platform but modifying their appearance.
|
||||||
|
@ -61,23 +61,28 @@ class ToolbarItemsParentData extends ContainerBoxParentData<RenderBox> {
|
|||||||
/// An interface for building the selection UI, to be provided by the
|
/// An interface for building the selection UI, to be provided by the
|
||||||
/// implementer of the toolbar widget.
|
/// 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]
|
/// ## 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
|
/// For backwards compatibility during the deprecation period, when
|
||||||
/// migration is necessary. First, migrate to [TextSelectionHandleControls],
|
/// [EditableText.selectionControls] is set to an object that does not mix in
|
||||||
/// using its [TextSelectionHandleControls.buildHandle] method and moving
|
/// [TextSelectionHandleControls], [EditableText.contextMenuBuilder] is ignored
|
||||||
/// toolbar code to [EditableText.contextMenuBuilder]. Later, the deprecation
|
/// in favor of the deprecated [buildToolbar].
|
||||||
/// period will expire, [buildToolbar] will be removed, and
|
///
|
||||||
/// [TextSelectionHandleControls] will be deprecated. Migrate back to
|
/// To migrate code from [buildToolbar] to the preferred
|
||||||
/// [TextSelectionControls.buildHandle], so that the final state is to use
|
/// [EditableText.contextMenuBuilder], while still using [buildHandle], mix in
|
||||||
/// [EditableText.contextMenuBuilder] for the toolbar and
|
/// [TextSelectionHandleControls] into the [TextSelectionControls] subclass when
|
||||||
/// [TextSelectionControls] for the handles.
|
/// 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 <https://docs.flutter.dev/release/breaking-changes/context-menus>.
|
||||||
///
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user