GlassFocusRegion class

A shared accessibility and focus region for interactive glass widgets.

Modes

Interactive mode (default constructor)

Encapsulates:

Observe mode (GlassFocusRegion.observe)

For text inputs and other widgets that already own their FocusNode (e.g. CupertinoTextField). In this mode the widget:

All keyboard intent handling and semantics remain with the wrapped widget.

Use this for GlassTextField, GlassSearchBar, or any widget where CupertinoTextField already manages the focus lifecycle.

State Lifting: In interactive mode, this region accepts ValueNotifiers from the parent widget and updates them, allowing the parent to react to hover/focus changes with zero additional rebuilds.

Inheritance

Constructors

GlassFocusRegion({required Widget child, required bool enabled, ShapeBorder? shape, FocusNode? observedFocusNode, ValueNotifier<bool>? isFocusedNotifier, ValueNotifier<bool>? isHoveredNotifier, FocusNode? focusNode, bool canRequestFocus = true, bool autofocus = false, String? semanticLabel, bool isButton = false, bool isSlider = false, bool tracksSelection = false, bool isSelected = false, bool? toggled, VoidCallback? onKeyboardActivate, VoidCallback? semanticOnTap, VoidCallback? semanticOnLongPress, String? semanticValue, String? semanticIncreasedValue, String? semanticDecreasedValue, VoidCallback? semanticOnIncrease, VoidCallback? semanticOnDecrease, Key? key})
Interactive mode: full keyboard traversal, semantics, and focus ring.
const
GlassFocusRegion.observe({required Widget child, required FocusNode focusNode, required ShapeBorder shape, Key? key})
Observe mode: paints the focus ring by listening to an external FocusNode without creating a FocusableActionDetector.

Properties

autofocus → bool
Whether to request focus immediately.
final
canRequestFocus → bool
Whether the widget can request focus.
final
child → Widget
The widget tree inside the focus region.
final
enabled → bool
Whether the widget is interactive and focusable.
final
focusNode → FocusNode?
Externally provided focus node (from the parent's widget parameter).
final
hashCode → int
The hash code for this object.
no setterinherited
isButton → bool
Whether this region should announce as a button to screen readers.
final
isFocusedNotifier → ValueNotifier<bool>?
A notifier that this region will update when keyboard focus arrives/leaves. If null, the region will manage its own internal state.
final
isHoveredNotifier → ValueNotifier<bool>?
A notifier that this region will update when mouse hover enters/exits. If null, the region will manage its own internal state.
final
isSelected → bool
Whether the widget is currently selected (if it supports selection).
final
isSlider → bool
Whether this is a slider for screen readers.
final
key → Key?
Controls how one widget replaces another widget in the tree.
finalinherited
observedFocusNode → FocusNode?
When non-null, this widget operates in "observe" mode.
final
onKeyboardActivate → VoidCallback?
Callback fired when the user presses Space or Enter while focused.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
semanticDecreasedValue → String?
Semantic decreased value for sliders.
final
semanticIncreasedValue → String?
Semantic increased value for sliders.
final
semanticLabel → String?
The semantic label for screen readers.
final
semanticOnDecrease → VoidCallback?
Callback for decreasing the slider value.
final
semanticOnIncrease → VoidCallback?
Callback for increasing the slider value.
final
semanticOnLongPress → VoidCallback?
Callback fired when screen readers invoke a long press.
final
semanticOnTap → VoidCallback?
Callback fired when screen readers invoke a tap.
final
semanticValue → String?
Semantic value for sliders (e.g. '50%').
final
shape → ShapeBorder?
The exact shape of the widget, used to draw the focus ring. If null, no visual focus ring is painted by this region.
final
toggled → bool?
The toggled state (for switches). If null, this semantic is not applied.
final
tracksSelection → bool
Whether this region participates in a mutual exclusivity group (like a segmented control).
final

Methods

createElement() → StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → State<GlassFocusRegion>
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