Focus class
A widget that manages a FocusNode to allow keyboard focus tracking and traversal in the widget tree.
Automatically mounts the supplied focusNode to the closest ancestor focus scope on State.didChangeDependencies and unmounts it on State.dispose to ensure the keyboard focus tree stays synchronized with the layout.
Example
final node = FocusNode();
Focus(
focusNode: node,
autofocus: true,
child: MyInputWidget(),
)
- Inheritance
-
- Object
- Widget
- StatefulWidget
- Focus
Constructors
Properties
- autofocus → bool
-
Whether this focus node should automatically request focus when mounted.
final
- child → Widget
-
The child subtree that this focus widget hosts.
final
- focusNode → FocusNode
-
The focus node that represents the focus handle.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
The optional key for this widget.
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → Element -
Creates an Element to manage this widget's location in the tree.
inherited
-
createState(
) → State< StatefulWidget> -
Creates the mutable state for this widget at a given location in the tree.
override
-
getIntrinsicHeight(
int width) → int -
Computes the intrinsic height of this widget under the given
widthconstraint.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
render(
Buffer buffer, Rect area) → void -
Renders the widget onto the provided
bufferwithin the specifiedarea.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
of(
BuildContext context) → FocusNode? - Finds the nearest ancestor FocusNode in the widget tree.