Adaptive constructor / TextInputAction docs (#69346)
This commit is contained in:
parent
cfcb9887c9
commit
24c6266230
@ -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<String>? onSubmitted;
|
||||
|
||||
/// {@macro flutter.widgets.editableText.inputFormatters}
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -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].
|
||||
///
|
||||
|
@ -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],
|
||||
|
@ -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<String>? onSubmitted;
|
||||
|
||||
/// {@macro flutter.widgets.editableText.onAppPrivateCommand}
|
||||
|
@ -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.
|
||||
///
|
||||
|
@ -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: <Widget>[
|
||||
/// 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<String>? onSubmitted;
|
||||
|
||||
/// {@template flutter.widgets.editableText.onAppPrivateCommand}
|
||||
|
Loading…
x
Reference in New Issue
Block a user