diff --git a/packages/flutter/lib/src/cupertino/text_field.dart b/packages/flutter/lib/src/cupertino/text_field.dart index f62fcb317b..8df402b238 100644 --- a/packages/flutter/lib/src/cupertino/text_field.dart +++ b/packages/flutter/lib/src/cupertino/text_field.dart @@ -506,9 +506,9 @@ class CupertinoTextField extends StatefulWidget { /// /// See also: /// - /// * [EditableText.onSubmitted] for an example of how to handle moving to - /// the next/previous field when using [TextInputAction.next] and - /// [TextInputAction.previous] for [textInputAction]. + /// * [TextInputAction.next] and [TextInputAction.previous], which + /// automatically shift the focus to the next/previous focusable item when + /// the user is done editing. final ValueChanged? onSubmitted; /// {@macro flutter.widgets.editableText.inputFormatters} diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index b8f611caf8..4497e40268 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -167,6 +167,10 @@ class Slider extends StatefulWidget { assert(divisions == null || divisions > 0), super(key: key); + /// Creates an adaptive [Slider] based on the target platform, following + /// Material design's + /// [Cross-platform guidelines](https://material.io/design/platform-guidance/cross-platform-adaptation.html). + /// /// Creates a [CupertinoSlider] if the target platform is iOS, creates a /// Material Design slider otherwise. /// diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index 8ee2cda5bb..02fd145a3b 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -90,11 +90,17 @@ class Switch extends StatefulWidget { assert(inactiveThumbImage != null || onInactiveThumbImageError == null), super(key: key); - /// Creates a [CupertinoSwitch] if the target platform is iOS, creates a - /// material design switch otherwise. + /// Creates an adaptive [Switch] based on whether the target platform is iOS + /// or macOS, following Material design's + /// [Cross-platform guidelines](https://material.io/design/platform-guidance/cross-platform-adaptation.html). /// - /// If a [CupertinoSwitch] is created, the following parameters are - /// ignored: [activeTrackColor], [inactiveThumbColor], [inactiveTrackColor], + /// On iOS and macOS, this constructor creates a [CupertinoSwitch], which has + /// matching functionality and presentation as Material switches, and are the + /// graphics expected on iOS. On other platforms, this creates a Material + /// design [Switch]. + /// + /// If a [CupertinoSwitch] is created, the following parameters are ignored: + /// [activeTrackColor], [inactiveThumbColor], [inactiveTrackColor], /// [activeThumbImage], [onActiveThumbImageError], [inactiveThumbImage], /// [onInactiveThumbImageError], [materialTapTargetSize]. /// diff --git a/packages/flutter/lib/src/material/switch_list_tile.dart b/packages/flutter/lib/src/material/switch_list_tile.dart index 84a6bdc9ad..c35f7967a4 100644 --- a/packages/flutter/lib/src/material/switch_list_tile.dart +++ b/packages/flutter/lib/src/material/switch_list_tile.dart @@ -284,10 +284,14 @@ class SwitchListTile extends StatelessWidget { assert(autofocus != null), super(key: key); - /// Creates the wrapped switch with [Switch.adaptive]. + /// Creates a Material [ListTile] with an adaptive [Switch], following + /// Material design's + /// [Cross-platform guidelines](https://material.io/design/platform-guidance/cross-platform-adaptation.html). /// - /// Creates a [CupertinoSwitch] if the target platform is iOS, creates a - /// material design switch otherwise. + /// This widget uses [Switch.adaptive] to change the graphics of the switch + /// component based on the ambient [ThemeData.platform]. On iOS and macOS, a + /// [CupertinoSwitch] will be used. On other platforms a Material design + /// [Switch] will be used. /// /// If a [CupertinoSwitch] is created, the following parameters are /// ignored: [activeTrackColor], [inactiveThumbColor], [inactiveTrackColor], diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 4d3e6cda22..98c1f78bfb 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -613,9 +613,9 @@ class TextField extends StatefulWidget { /// /// See also: /// - /// * [EditableText.onSubmitted] for an example of how to handle moving to - /// the next/previous field when using [TextInputAction.next] and - /// [TextInputAction.previous] for [textInputAction]. + /// * [TextInputAction.next] and [TextInputAction.previous], which + /// automatically shift the focus to the next/previous focusable item when + /// the user is done editing. final ValueChanged? onSubmitted; /// {@macro flutter.widgets.editableText.onAppPrivateCommand} diff --git a/packages/flutter/lib/src/services/text_input.dart b/packages/flutter/lib/src/services/text_input.dart index 948cc6a4b9..d5d44ca439 100644 --- a/packages/flutter/lib/src/services/text_input.dart +++ b/packages/flutter/lib/src/services/text_input.dart @@ -225,8 +225,9 @@ class TextInputType { /// /// Despite the logical meaning of each action, choosing a particular /// [TextInputAction] does not necessarily cause any specific behavior to -/// happen. It is up to the developer to ensure that the behavior that occurs -/// when an action button is pressed is appropriate for the action button chosen. +/// happen, other than changing the focus when approapriate. It is up to the +/// developer to ensure that the behavior that occurs when an action button is +/// pressed is appropriate for the action button chosen. /// /// For example: If the user presses the keyboard action button on iOS when it /// reads "Emergency Call", the result should not be a focus change to the next @@ -314,6 +315,8 @@ enum TextInputAction { /// Logical meaning: The user is done with the current input source and wants /// to move to the next one. /// + /// Moves the focus to the next focusable item in the same [FocusScope]. + /// /// Android: Corresponds to Android's "IME_ACTION_NEXT". The OS displays a /// button that represents moving forward, e.g., a right-facing arrow button. /// @@ -324,6 +327,8 @@ enum TextInputAction { /// Logical meaning: The user wishes to return to the previous input source /// in the group, e.g., a form with multiple [TextField]s. /// + /// Moves the focus to the previous focusable item in the same [FocusScope]. + /// /// Android: Corresponds to Android's "IME_ACTION_PREVIOUS". The OS displays a /// button that represents moving backward, e.g., a left-facing arrow button. /// diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 6a02ac6bf7..78e6ecb409 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -1021,63 +1021,6 @@ class EditableText extends StatefulWidget { /// Called when the user indicates that they are done editing the text in the /// field. /// {@endtemplate} - /// - /// {@tool dartpad --template=stateful_widget_material} - /// When a non-completion action is pressed, such as "next" or "previous", it - /// is often desirable to move the focus to the next or previous field. To do - /// this, handle it as in this example, by calling [FocusNode.nextFocus] in - /// the `onFieldSubmitted` callback of [TextFormField]. ([TextFormField] wraps - /// [EditableText] internally, and uses the value of `onFieldSubmitted` as its - /// [onSubmitted]). - /// - /// ```dart - /// FocusScopeNode _focusScopeNode = FocusScopeNode(); - /// final _controller1 = TextEditingController(); - /// final _controller2 = TextEditingController(); - /// - /// void dispose() { - /// _focusScopeNode.dispose(); - /// _controller1.dispose(); - /// _controller2.dispose(); - /// super.dispose(); - /// } - /// - /// void _handleSubmitted(String value) { - /// _focusScopeNode.nextFocus(); - /// } - /// - /// Widget build(BuildContext context) { - /// return Scaffold( - /// body: FocusScope( - /// node: _focusScopeNode, - /// child: Column( - /// mainAxisAlignment: MainAxisAlignment.center, - /// children: [ - /// Padding( - /// padding: const EdgeInsets.all(8.0), - /// child: TextFormField( - /// textInputAction: TextInputAction.next, - /// onFieldSubmitted: _handleSubmitted, - /// controller: _controller1, - /// decoration: InputDecoration(border: OutlineInputBorder()), - /// ), - /// ), - /// Padding( - /// padding: const EdgeInsets.all(8.0), - /// child: TextFormField( - /// textInputAction: TextInputAction.next, - /// onFieldSubmitted: _handleSubmitted, - /// controller: _controller2, - /// decoration: InputDecoration(border: OutlineInputBorder()), - /// ), - /// ), - /// ], - /// ), - /// ), - /// ); - /// } - /// ``` - /// {@end-tool} final ValueChanged? onSubmitted; /// {@template flutter.widgets.editableText.onAppPrivateCommand}