Sub topic 1
Why Accessibility Matters and Who It Serves
Prerequisites
You should know basic Dart syntax, how to build layouts with Flutter widgets, and how to run an app on an emulator or device. You should also understand StatelessWidget and StatefulWidget.
Why accessibility matters
Accessibility means that people with visual, motor, hearing, or cognitive impairments can use your app. Many of them rely on screen readers, large text, high contrast, or keyboard navigation. Accessibility also helps people with temporary limits, such as a broken arm or a screen in bright sunlight.
How Flutter describes your UI to assistive technology
Flutter builds a semantics tree alongside the widget tree. The semantics tree stores labels, roles, values, and actions for each part of the screen. Flutter passes this tree to the platform, where TalkBack on Android and VoiceOver on iOS read it aloud.
Trying your app with TalkBack and VoiceOver
On Android, open Settings, then Accessibility, then TalkBack, and turn it on. On iOS, open Settings, then Accessibility, then VoiceOver, and turn it on. Swipe right to move focus to the next element, and double-tap to activate the focused element. Listen for each control's name and role. If you hear only "button" or nothing at all, the control needs a label.
What Flutter widgets give you for free
Standard widgets such as Text, Checkbox, and IconButton already provide labels and roles. IconButton uses its tooltip as its label, so a screen reader announces a named button instead of an unlabeled icon.
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Accessible demo')),
body: Center(
child: IconButton(
icon: const Icon(Icons.favorite_border),
tooltip: 'Add to favorites',
onPressed: () {},
),
),
),
);
}
}Run this app with TalkBack or VoiceOver on. The button announces "Add to favorites" and identifies itself as a button.
Exercise
A screen reader announces an IconButton with no name. Which property should you set, and what does it change?
Show answer
Set the tooltip property. Flutter uses the tooltip as the button's accessibility label, so the screen reader announces the name instead of an unlabeled icon.