FocusScopeNode class
A specialized focus scope node that manages focus traversal.
Grouping interactive focus nodes inside a FocusScopeNode enables cycling focus among its descendants (e.g. by pressing Tab for forward cycles or Shift-Tab for backward cycles). It keeps track of the currently active focused child in the scope.
Traversal APIs
- nextFocus(): Move focus to the next child in children.
- previousFocus(): Move focus to the previous child in children.
Constructors
- FocusScopeNode({required String id})
-
Creates a FocusScopeNode with the given
id.
Properties
-
children
→ List<
FocusNode> -
The child nodes nested under this node.
finalinherited
- focusedChild → FocusNode?
-
The active focused child node inside this scope.
no setter
- hasFocus → bool
-
Whether this node has focus.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasPrimaryFocus → bool
-
Whether this node has primary focus, meaning it is focused and none of its children are.
no setterinherited
- id → String
-
Unique identifier of the focus node (useful for debugging).
finalinherited
- isFocused ↔ bool
-
Whether this node currently holds keyboard focus.
getter/setter pairinherited
- onFocusChange ↔ void Function(bool hasFocus)?
-
Callback executed when this focus node gains or loses focus.
getter/setter pairinherited
- onKeyEvent ↔ bool Function(KeyEvent event)?
-
Callback executed when a key event hits this node.
Return
trueto consume the keypress and prevent it from bubbling up the tree.getter/setter pairinherited - parent ↔ FocusNode?
-
The parent focus node, if any.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addChild(
FocusNode child) → void -
Adds a child focus node to this branch.
inherited
-
bubbleKeyEvent(
KeyEvent event) → bool -
Traverses up from the primary focus node to let nodes consume keypresses.
inherited
-
findFocusedLeaf(
) → FocusNode? -
Traverses down the focused path to find the deeply focused leaf node.
inherited
-
nextFocus(
) → void - Cycles keyboard focus forward to the next sibling in the scope's focus list.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
previousFocus(
) → void - Cycles keyboard focus backward to the previous sibling in the focus list.
-
requestFocus(
) → void -
Requests focus for this node, unfocusing other sibling branches recursively.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
unfocus(
) → void -
Removes focus from this node and its descendants.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited