StreamAccessibilityAutofocus class
A behavior-only wrapper that requests screen-reader focus on child shortly after mount.
Use this when the platform's automatic focus decision on route entry (typically the first interactive element in the toolbar) is not the element the user needs to interact with — for example, landing focus on a message input rather than the back button when a chat screen opens.
Only the screen-reader reading cursor is moved; input focus is not requested, so the soft keyboard stays closed.
The wrapper is a passthrough when MediaQueryData.accessibleNavigation is false, so it has no effect for sighted users. It also responds to the screen reader being turned on or off at runtime.
Only one StreamAccessibilityAutofocus should be active per route. When two instances compete for screen-reader focus, the reading cursor visibly bounces between their targets.
{@tool snippet}
Land SR focus on the composer input when the message screen opens:
StreamAccessibilityAutofocus(
child: StreamMessageComposerInputField(...),
)
{@end-tool}
See also:
- FocusSemanticEvent, which this widget dispatches to move the SR reading cursor.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- StreamAccessibilityAutofocus
Constructors
Properties
- child → Widget
-
The widget whose semantic node should receive SR focus.
final
- enabled → bool
-
Whether the wrapper should attempt to move SR focus at all.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- retryInterval → Duration
-
How often the wrapper reattempts focus during window.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- window → Duration
-
How long to keep reattempting focus after mount.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< StreamAccessibilityAutofocus> -
Creates the mutable state for this widget at a given location in the tree.
override
-
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
-
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, int wrapWidth = 65}) → 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
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited