FocusManager class

Inheritance

Constructors

FocusManager()

Properties

attachedNodes → Iterable<FocusNode>
Read-only view of every node currently attached to this manager, in attachment order. FocusTraversalGroup uses this to find candidates for directional focus.
no setter
focusedNode → FocusNode?
The currently focused node, or null when nothing is focused.
no setter
focusedNodeClaimsText → bool
Whether the focused node claims typed text (a focused, editable TextInput). While true, chords shadowed by text input (KeySequence.isShadowedByTextInput) can never fire — the claimant consumes the characters before chord matching runs. The hint bar uses this to hide such bindings instead of advertising dead keys.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether at least one listener is registered.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

activeChain() → List<FocusNode>
Returns the focus chain from focusedNode up to the root, in deepest-first order, by walking element parents.
addListener(VoidCallback listener) → void
Registers listener to be called when this object changes.
inherited
dispose() → void
Marks this notifier as disposed and drops its listeners. Nulls the slots in place (rather than replacing the backing list) so a dispose called from within a listener leaves any in-progress notify walk reading valid, now-empty slots. After disposal, addListener and notify throw; removeListener remains safe for cleanup.
override
focusNext({BuildContext? scopeContext}) → bool
Moves focus to the next focusable node in reading order (top-to-bottom, then left-to-right), cycling at the end. Skips nodes that can't take focus or are flagged skipTraversal. Returns whether focus moved. This is the mechanism behind Tab traversal; the key bindings live in FocusTraversalGroup.
focusPrevious({BuildContext? scopeContext}) → bool
Moves focus to the previous focusable node in reading order, cycling at the start. If scopeContext is supplied, only nodes below it participate.
isTraversable(FocusNode node) → bool
Whether node is currently traversable: it can take focus, isn't flagged skipTraversal, and sits under no active ExcludeFocus. Both the Tab and the arrow-key policies consult this.
liftExclusionIn(BuildContext root) → void
Lifts the outermost active ExcludeFocus marker(s) inside root, ahead of the rebuild that will flip them off. For containers that reveal previously covered content by intent (Navigator.pop wraps each route in ExcludeFocus(excluding: !isTop)): the reveal is decided NOW, but the marker widget only updates next frame — lifting eagerly lets focus restoration run synchronously and lets app code claim focus into the revealed subtree from completion microtasks. The walk never descends past a marker, so an app's own nested ExcludeFocus (a hidden tab, say) stays excluded; each lifted marker re-syncs to its widget configuration on its next update.
listen(VoidCallback listener) → VoidCallback
Registers listener and returns an idempotent cancellation function.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify() → void
Publishes a change to every listener registered when the pass began.
inherited
notifyBindingsChanged() → void
Called by KeyBindings when its binding list changes in place (a rebuild produced a new list — new labels, enabled flags, or chords) without any focus movement. Notifies manager listeners (the hint bar depends on the manager) so they repaint against the new bindings. On a microtask — this is invoked from didUpdateWidget, mid-build, where a synchronous notify would re-enter setState on a dependent.
releaseFocusTrapIn(BuildContext? context) → void
Releases the nearest trapping FocusScope enclosing context immediately, ahead of the rebuild that will flip its trapFocus flag off or remove the scope.
removeListener(VoidCallback listener) → void
Removes a previously-registered listener.
inherited
requestFocus(FocusNode? node, {bool reveal = true}) → bool
Requests that node become the focused node (null to clear focus). Returns whether focus actually moved.
restoreFocusInScope(BuildContext? context) → bool
Restores focus to the node most recently focused within the nearest FocusScope enclosing context (the scope's focus memory). Returns whether focus moved.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

maybeOf(BuildContext context) → FocusManager?
The surrounding FocusManager, or null if there isn't one. See of.
of(BuildContext context) → FocusManager
The surrounding FocusManager. Throws when there isn't one — the manager is installed by runApp.