Flutter › Accessibility in Flutter Apps
What is the Semantics widget in Flutter, and how does it help screen readers correctly describe the content and purpose of a widget to a visually impaired user?
BeginnerAnswer
The Semantics widget lets you attach additional descriptive information to a part of your widget tree, such as a readable label, a hint describing what will happen when the widget is activated, or a value representing its current state, and screen reader software such as TalkBack on Android or VoiceOver on iOS reads this semantic information aloud to a visually impaired user, letting them understand and interact with a widget even though they cannot actually see it on the screen.
Semantics(
label: 'Increase quantity',
child: IconButton(icon: Icon(Icons.add), onPressed: incrementQuantity),
)Real-world example A shopping cart screen wraps its plus and minus quantity icon buttons in Semantics widgets with clear labels, ensuring a screen reader announces exactly what each button does instead of just saying icon button.