Accessibility in mobile apps is more than just a feature—it's a necessity. By making apps accessible, developers ensure inclusivity and usability for users with diverse abilities. This also aligns with legal requirements, helping to mitigate risks of non-compliance.
Why Accessibility matters in Mobile Apps
Accessible apps enable an inclusive experience for everyone, improving usability for users with visual, auditory, motor or cognitive impairments. Accessibility also fulfills legal requirements in many countries, helping to avoid potential lawsuits.
A11Y Standards
- Level A: Basic accessibility, ensuring fundamental usability.
- Level AA: Addresses most accessibility issues and is legally required in many countries.
- Level AAA: The highest accessibility level but not always practical.
Even simple accessibility adjustments can have a big impact. However, not all apps meet even the most basic requirements.
Screen contrast: ensuring Readability
Let’s start with the easiest one. High contrast ratios are essential for readability, particularly for users with visual impairments. When selecting text colors in your app, aim for a minimum contrast ratio of 4.5:1 for standard text and 3:1 for larger text. To ensure your app meets these standards, use tools like a contrast checker tool to verify contrast compliance across your UI. Additionally, you can automate this process by running widget tests to ensure consistent contrast compliance—a topic we’ll cover later in this article.
Accessible font sizes
The Web Content Accessibility Guidelines (WCAG) recommend a minimum font size of 16px (approximately 12pt) to maintain readability and legibility across devices. This guideline helps to make sure that text is comfortable to read for users, including those with visual impairments. Testing the app with different text scale settings is essential to catch potential overflow issues and to verify that all content remains visible and understandable at various sizes.
Using screen readers in Flutter
Screen readers such as TalkBack (Android) and VoiceOver (iOS) interpret app content for visually impaired users. Flutter Semantics widget enriches accessibility providing labels that would be used by the engine reader to provide a more suitable experience. Basic widgets in Flutter are accessible out of the box, but adding semantic customizations can greatly enhance user experience.
If you’re interested in enabling TalkBack or VoiceOver on your device here are some official guides on how to enable accessibility on your device.
Semantic widgets for Accessibility
Let’s go through some of the accessibility widgets that the Flutter SDK provide to us:
Semantics Widget
Add semantic information to any widget just wrapping it and adding a label parameter. That label will be used by the accessibility engines to provide a description of the behavior of that widget.
The Semantics widget has a lot of properties to identify which kind of widget you are wrapping so it can be easily identified by the engine.
ExcludeSemantics
Exclude irrelevant information from the Semantics Tree. If certain elements aren’t useful, you can simply exclude them, and they will be ignored by the screen readers. This keeps the Semantics Tree clean and focused on meaningful content for users.
MergeSemantics
Combine multiple widgets into one semantic node for simpler screen reader interpretation. Most of the time there's a group of widgets that should be interpreted as once, but this is not clear for the screen reader so we should specify it to improve readability. In the example below the screen will merge the accessibility information of both text widgets and read it as one widget.
OrdinalSortKey
The OrdinalSortKey defines a reading order for screen readers, ensuring smooth and logical navigation through the app. It assigns a numeric value to each widget, allowing screen readers to determine the sequence based on these values, rather than the default widget order in the semantics tree. This approach improves user experience by guiding them through content in the intended logical flow.
Accessibility tools in Flutter
Testing accessibility can feel exhausting, especially in larger applications where verifying screen reader compatibility and checking color contrast across the entire app is time-consuming. Fortunately, there are several accessibility-focused packages on pub.dev that can simplify this process. My top recommendation is the accessibility_tools package, which significantly streamlined my workflow when building accessible apps.
To get started, add accessibility_tools to your pubspec.yaml, and then wrap your app’s root widget with the AccessibilityTools widget. This quick setup makes it easier to catch and resolve accessibility issues from the start.
As a result, you’ll see the accessibility tools screen appear within your app, providing immediate insights into accessibility features. This screen is only visible in development mode, so it won’t appear in release or profile builds 😉
Unit testing for Accessibility
Including tests in our codebases automatically ensures that code changes don’t degrade accessibility. The Flutter SDK allows verification of accessibility compliance through the following methods.
- bySemanticsLabel - Finds Semantics widget matching the given label.
- getSemantics - Attempts to find the SemanticsNode of first result from finder
- matchesSemantics - Asserts that a SemanticsNode contains the specified information
- meetsGuideline - Asserts that the currently rendered widget meets the provided accessibility guideline The supported guidelines are androidTapTargetGuideline, iOSTapTargetGuideline, textContrastGuideline, and labeledTapTargetGuideline.
Bonus: Testing Accessibility on Flutter Web
Since web is not one of the biggest perks on the Flutter ecosystem, there’s some kind of workaround to ensure your accessible apps work as expected on web browsers. But don’t worry you can just easily check it by running the below command on your terminal.
Making mobile applications accessible is crucial so that they can be used effectively by everyone. With Flutter’s semantic widgets, you can build more inclusive and user-friendly apps with minimal additional effort. Additionally, consider incorporating accessibility-focused packages to improve your development process.
For a complete example of accessibility implementation in a Flutter app, check out our Flutter tips video #8 or this Flutter Accessibility Example.
For a broader perspective on developing scalable and maintainable Flutter applications, check out our article 13 best practices for Flutter performance optimization
If you’re searching for a trusted software development partner, look no further. Contact us today to learn how we can help you turn your vision into reality with our tailored, high-quality solutions.