SemanticsComponent class Accessibility

Exposes the owning Node to assistive technology (screen readers, switch access) as one element of the enclosing SceneView's semantics.

Scene content is opaque to accessibility by default. Attaching a SemanticsComponent to a node publishes it as a semantics element whose focus rectangle is the node's bounds projected through the view's camera, recomputed as the camera and the node move. Actions (onTap, onIncrease, onDecrease, and anything else set through properties) are invoked directly by the platform's accessibility system; they do not pass through scene raycasting.

node.addComponent(SemanticsComponent(
  label: 'Power switch',
  button: true,
  onTap: togglePower,
));

The focus rectangle covers the node's `combinedLocalBounds` (the node's mesh and all descendants). Set boundsOverride when that is wrong for focus, and for subtrees with no computable bounds (skinned content), which otherwise project as a nominal-size rectangle at the node origin.

Elements read in scene-graph order; set sortOrder to control traversal explicitly. While the node is invisible (or, with occlusionHiding, is occluded) it is removed from the semantics tree.

The convenience parameters cover common cases; pass a full SemanticsProperties as properties for anything else (sliders, live regions, custom actions). The two forms are mutually exclusive.

Inheritance

Constructors

SemanticsComponent({String? label, String? value, String? hint, bool button = false, VoidCallback? onTap, VoidCallback? onLongPress, VoidCallback? onIncrease, VoidCallback? onDecrease, VoidCallback? onDidGainAccessibilityFocus, VoidCallback? onDidLoseAccessibilityFocus, double? sortOrder, TextDirection? textDirection, bool occlusionHiding = false, Aabb3? boundsOverride, SemanticsProperties? properties})
Creates semantics for the owning node.

Properties

boundsOverride ↔ Aabb3?
Local-space bounds to project as the focus rectangle, replacing the node's own combined bounds.
getter/setter pair
button bool
Whether the node behaves like a button.
getter/setter pair
enabled bool
Whether this component's update hook runs each frame.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
hint String?
A brief description of what interacting with the node does.
getter/setter pair
isAttached bool
Whether this component is currently attached to a node.
no setterinherited
isLoaded bool
Whether onLoad has completed.
no setterinherited
isMounted bool
Whether the owning node is part of a live scene graph.
no setterinherited
label String?
A short description of the node, read by the screen reader.
getter/setter pair
node Node
The node this component is attached to.
no setterinherited
occlusionHiding bool
Whether the node leaves the semantics tree while scene geometry occludes it from the camera. Defaults to false (an occluded node stays focusable), matching how a partially obscured widget behaves.
getter/setter pair
onDecrease VoidCallback?
Called when assistive technology decreases the node's value.
getter/setter pair
onDidGainAccessibilityFocus VoidCallback?
Called when the node gains accessibility focus (the screen-reader cursor lands on it). A natural place to draw an in-scene focus indicator (a Node.highlightColor outline) or steer the camera.
getter/setter pair
onDidLoseAccessibilityFocus VoidCallback?
Called when the node loses accessibility focus.
getter/setter pair
onIncrease VoidCallback?
Called when assistive technology increases the node's value.
getter/setter pair
onLongPress VoidCallback?
Called when assistive technology long-presses the node.
getter/setter pair
onTap VoidCallback?
Called when assistive technology activates the node (for example a VoiceOver double tap).
getter/setter pair
properties SemanticsProperties?
The full semantics configuration, for anything beyond the convenience parameters. Mutually exclusive with them.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sortOrder double?
The node's position in the accessibility traversal order, lower values first. Elements without a sort order read in scene-graph order.
getter/setter pair
textDirection TextDirection?
The reading direction of label, value, and hint. When null (the default) the enclosing SceneView's ambient Directionality is used.
getter/setter pair
value String?
The current value the node represents (for example a reading on a gauge), read after label.
getter/setter pair

Methods

cloneFor(Node cloneOwner) Component?
Returns a copy of this component for cloneOwner, the Node.clone counterpart of the owning node, or null to not carry the component to clones (the default).
inherited
fixedUpdate(double fixedDt) → void
Called once per fixed physics step while the component is mounted, enabled, and loaded. fixedDt is the fixed timestep of the surrounding PhysicsWorld, not the frame interval.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAttach() → void
Called when this component is added to a node.
inherited
onDetach() → void
Called when this component is removed from a node.
inherited
onLoad() Future<void>
Optional asynchronous setup, such as loading an asset.
inherited
onMount() → void
Called when the owning node enters a live scene graph.
override
onUnmount() → void
Called when the owning node leaves a live scene graph.
override
toString() String
A string representation of this object.
inherited
update(double deltaSeconds) → void
Called once per frame while the component is mounted, enabled, and loaded. deltaSeconds is the elapsed time since the previous tick.
inherited

Operators

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