One of the target platforms the Flutter framework supports is the web. Flutter applications guarantee pixel perfection and platform consistency throug

Accessibility in Flutter on the Web

submited by
Style Pass
2024-04-17 12:00:02

One of the target platforms the Flutter framework supports is the web. Flutter applications guarantee pixel perfection and platform consistency through rendering all UI onto a canvas element. However, by default canvas elements are not accessible. This case study explains how accessibility support works for such canvas-rendered Flutter apps.

Flutter has a large number of default widgets that generate an accessibility tree automatically. An accessibility tree is a tree of accessibility objects that assistive technology can query for attributes and properties and perform actions on. For custom widgets, Flutter’s Semantics class lets developers describe the meaning of their widgets, helping assistive technologies make sense of the widget content.

For performance reasons, at the time of this writing, Flutter’s accessibility is opt-in by default. The Flutter team would like to eventually turn the semantics on by default in Flutter Web. However, at the moment, this would lead to noticeable performance costs in a significant number of cases, and requires some optimization before the default can be changed. Developers who want to always turn on Flutter’s accessibility mode can do so with the following code snippet.

Leave a Comment