scrollPhysics property
Whether onTap should be called for every tap.
Defaults to false, so onTap is only called for each distinct tap. When enabled, onTap is called for every tap including consecutive taps. Called for each tap down that occurs outside of the TextFieldTapRegion group when the text field is focused.
If this is null, EditableTextTapOutsideIntent will be invoked. In the default implementation, FocusNode.unfocus will be called on the focusNode for this text field when a PointerDownEvent is received on another part of the UI. However, it will not unfocus as a result of mobile application touch events (which does not include mouse clicks), to conform with the platform conventions. To change this behavior, a callback may be set here or EditableTextTapOutsideIntent may be overridden.
When adding additional controls to a text field (for example, a spinner, a button that copies the selected text, or modifies formatting), it is helpful if tapping on that control doesn't unfocus the text field. In order for an external widget to be considered as part of the text field for the purposes of tapping "outside" of the field, wrap the control in a TextFieldTapRegion.
The PointerDownEvent passed to the function is the event that caused the notification. It is possible that the event may occur outside of the immediate bounding box defined by the text field, although it will be within the bounding box of a TextFieldTapRegion member.
{@tool dartpad}
This example shows how to use a TextFieldTapRegion to wrap a set of
"spinner" buttons that increment and decrement a value in the TextField
without causing the text field to lose keyboard focus.
This example includes a generic SpinnerField<T> class that you can copy
into your own project and customize.
** See code in examples/api/lib/widgets/tap_region/text_field_tap_region.0.dart ** {@end-tool}
See also:
- TapRegion for how the region group is determined. The cursor for a mouse pointer when it enters or is hovering over the widget.
If mouseCursor is a MaterialStateProperty<MouseCursor>,
MaterialStateProperty.resolve is used for the following MaterialStates:
If this property is null, MaterialStateMouseCursor.textable will be used.
The mouseCursor is the only property of TextField that controls the
appearance of the mouse pointer. All other properties related to "cursor"
stand for the text cursor, which is usually a blinking vertical line at
the editing position.
Callback that generates a custom InputDecoration.counter widget.
See InputCounterWidgetBuilder for an explanation of the passed in arguments. The returned widget will be placed below the line in place of the default widget built when InputDecoration.counterText is specified.
The returned widget will be wrapped in a Semantics widget for accessibility, but it also needs to be accessible itself. For example, if returning a Text widget, set the Text.semanticsLabel property.
{@tool snippet}
Widget counter(
BuildContext context,
{
required int currentLength,
required int? maxLength,
required bool isFocused,
}
) {
return Text(
'$currentLength of $maxLength characters',
semanticsLabel: 'character count',
);
}
{@end-tool}
If buildCounter returns null, then no counter and no Semantics widget will be created at all. The ScrollPhysics to use when vertically scrolling the input.
If not specified, it will behave according to the current platform.
See Scrollable.physics.
Implementation
// final bool onTapAlwaysCalled;
/// {@macro flutter.widgets.editableText.onTapOutside}
///
/// {@tool dartpad}
/// This example shows how to use a `TextFieldTapRegion` to wrap a set of
/// "spinner" buttons that increment and decrement a value in the [TextField]
/// without causing the text field to lose keyboard focus.
///
/// This example includes a generic `SpinnerField<T>` class that you can copy
/// into your own project and customize.
///
/// ** See code in examples/api/lib/widgets/tap_region/text_field_tap_region.0.dart **
/// {@end-tool}
///
/// See also:
///
/// * [TapRegion] for how the region group is determined.
// final TapRegionCallback? onTapOutside;
/// The cursor for a mouse pointer when it enters or is hovering over the
/// widget.
///
/// If [mouseCursor] is a [MaterialStateProperty<MouseCursor>],
/// [MaterialStateProperty.resolve] is used for the following [MaterialState]s:
///
/// * [MaterialState.error].
/// * [MaterialState.hovered].
/// * [MaterialState.focused].
/// * [MaterialState.disabled].
///
/// If this property is null, [MaterialStateMouseCursor.textable] will be used.
///
/// The [mouseCursor] is the only property of [TextField] that controls the
/// appearance of the mouse pointer. All other properties related to "cursor"
/// stand for the text cursor, which is usually a blinking vertical line at
/// the editing position.
// final MouseCursor? mouseCursor;
/// Callback that generates a custom [InputDecoration.counter] widget.
///
/// See [InputCounterWidgetBuilder] for an explanation of the passed in
/// arguments. The returned widget will be placed below the line in place of
/// the default widget built when [InputDecoration.counterText] is specified.
///
/// The returned widget will be wrapped in a [Semantics] widget for
/// accessibility, but it also needs to be accessible itself. For example,
/// if returning a Text widget, set the [Text.semanticsLabel] property.
///
/// {@tool snippet}
/// ```dart
/// Widget counter(
/// BuildContext context,
/// {
/// required int currentLength,
/// required int? maxLength,
/// required bool isFocused,
/// }
/// ) {
/// return Text(
/// '$currentLength of $maxLength characters',
/// semanticsLabel: 'character count',
/// );
/// }
/// ```
/// {@end-tool}
///
/// If buildCounter returns null, then no counter and no Semantics widget will
/// be created at all.
// final InputCounterWidgetBuilder? buildCounter;
/// {@macro flutter.widgets.editableText.scrollPhysics}
final ScrollPhysics? scrollPhysics;