FocusManager class

Manages the focus tree.

The focus tree keeps track of which FocusNode is the user's current keyboard focus. The widget that owns the FocusNode often listens for keyboard events.

The focus manager is responsible for holding the FocusScopeNode that is the root of the focus tree and tracking which FocusNode has the overall focus.

The FocusManager is held by the WidgetsBinding as WidgetsBinding.focusManager. The FocusManager is rarely accessed directly. Instead, to find the FocusScopeNode for a given BuildContext, use FocusScope.of.

The FocusManager knows nothing about FocusNodes other than the one that is currently focused. If a FocusScopeNode is removed, then the FocusManager will attempt to focus the next FocusScopeNode in the focus tree that it maintains, but if the current focus in that FocusScopeNode is null, it will stop there, and no FocusNode will have focus.

See also:

Mixed in types

Constructors

FocusManager()
Creates an object that manages the focus tree. [...]

Properties

highlightMode FocusHighlightMode
Indicates the current interaction mode for focus highlights. [...]
read-only
highlightStrategy FocusHighlightStrategy
Sets the strategy by which highlightMode is determined. [...]
read / write
primaryFocus FocusNode
The node that currently has the primary focus.
read-only
rootScope FocusScopeNode
The root FocusScopeNode in the focus tree. [...]
final
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

addHighlightModeListener(ValueChanged<FocusHighlightMode> listener) → void
Register a closure to be called when the FocusManager notifies its listeners that the value of highlightMode has changed.
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children. [...]
override
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node. [...]
override
removeHighlightModeListener(ValueChanged<FocusHighlightMode> listener) → void
Remove a previously registered closure from the list of closures that the FocusManager notifies.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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.debug }) String
Returns 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 brief description of this object, usually just the runtimeType and the hashCode. [...]
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited