dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.29k stars 1.59k forks source link

proposal: missing_alt_text #59178

Open gregorscholz opened 1 year ago

gregorscholz commented 1 year ago

missing_alt_name

Description

Image widget should be accessible for everybody and therefore contain an alt text.

Details

For vision impaired people images can be annoying, they often use screen readers to get the information on the page. To also get information about the images, Image widgets should contain a semanticLabel.

Bad Examples

Image(
    image: AssetImage('user_profile_picture'),
),

Good Examples

Image(
    image: AssetImage('user_profile_picture'),
    semanticLabel: 'profile picture',
),

Discussion

With a semanticLabel added, people using screen readers can get a better overview of what information is displayed on the screen. We as a community want to be open for everybody as much as we want be build applications which are accessible for everyone.

Also mentioned here: 2300

srawlins commented 1 year ago

CC @goderbauer

lrhn commented 1 year ago

If this is as important as this, should the parameter be made required directly in Flutter instead?

IchordeDionysos commented 1 year ago

@lrhn might prompt users just to put an empty string which is even worse because an empty string indicates to screen readers that an image is just a decorative image.

And it would make it nearly impossible for automated A11y checks to distinguish whether an alt text is missing or just omitted for decorative images.

lrhn commented 1 year ago

I can see the argument that you may omit alt-texts during development, but want to be reminded to add them before release. A warning is better for that than an error.

(Should we have a way to make a parameter recommended, so it's a warning to not pass it, but not an error? Or only optional in development mode, not production.?)

gregorscholz commented 1 year ago

I would also vote for it beeing a warning instead of an error.