TextFieldTapRegion class

A TapRegion that adds its children to the tap region group for widgets based on the EditableText text editing widget, such as TextField and CupertinoTextField.

Widgets that are wrapped with a TextFieldTapRegion are considered to be part of a text field for purposes of unfocus behavior. So, when the user taps on them, the currently focused text field won't be unfocused by default. This allows controls like spinners, copy buttons, and formatting buttons to be associated with a text field without causing the text field to lose focus when they are interacted with.

This example shows how to use a TextFieldTapRegion to wrap a set of "spinner" buttons that increment and decrement a value in the text field without causing the text field to lose keyboard focus.

This example includes a generic SpinnerField<T> class that you can copy/paste into your own project and customize.

link

To create a local project with this code sample, run:
flutter create --sample=widgets.TextFieldTapRegion.1 mysample

See also:

  • TapRegion, the widget that this widget uses to add widgets to the group of text fields.
Inheritance

Constructors

TextFieldTapRegion({Key? key, required Widget? child, bool enabled = true, TapRegionCallback? onTapOutside, TapRegionCallback? onTapInside, bool consumeOutsideTaps = false, String? debugLabel, Object? groupId = EditableText})
Creates a const TextFieldTapRegion.
const

Properties

behavior HitTestBehavior
How to behave during hit testing when deciding how the hit test propagates to children and whether to consider targets behind this TapRegion.
finalinherited
child Widget?
The widget below this widget in the tree.
finalinherited
consumeOutsideTaps bool
If true, then the group that this region belongs to will stop the propagation of the tap down event in the gesture arena.
finalinherited
debugLabel String?
An optional debug label to help with debugging in debug mode.
finalinherited
enabled bool
Whether or not this TapRegion is enabled as part of the composite region.
finalinherited
groupId Object?
An optional group ID that groups TapRegions together so that they operate as one region. If any member of a group is hit by a particular tap, then the onTapOutside will not be called for any members of the group. If any member of the group is hit, then all members will have their onTapInside called.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onTapInside TapRegionCallback?
A callback to be invoked when a tap is detected inside of this TapRegion, or any other tap region with the same groupId, if any.
finalinherited
onTapOutside TapRegionCallback?
A callback to be invoked when a tap is detected outside of this TapRegion and any other region with the same groupId, if any.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() SingleChildRenderObjectElement
RenderObjectWidgets always inflate to a RenderObjectElement subclass.
inherited
createRenderObject(BuildContext context) RenderObject
Creates an instance of the RenderObject class that this RenderObjectWidget represents, using the configuration described by this RenderObjectWidget.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
didUnmountRenderObject(covariant RenderObject renderObject) → void
A render object previously associated with this widget has been removed from the tree. The given RenderObject will be of the same type as returned by this object's createRenderObject.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited
updateRenderObject(BuildContext context, covariant RenderTapRegion renderObject) → void
Copies the configuration described by this RenderObjectWidget to the given RenderObject, which will be of the same type as returned by this object's createRenderObject.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited