Skip to content

[a11y] Use defaultTargetPlatform instead of platform from the theme for Semantics flags in a few widgets #176566

@huycozy

Description

@huycozy

Use case

I noticed this @chunhtai's comment at #173418 (comment):

"we should check defaultTargetPlatform instead of from the theme, if for some reason someone wants android feels and look on an iOS, the voice over will still be broken"

Indeed, in case users explicitly configure a specific platform (let's give it as Android for eg), but run on another platforms (let's give it as iOS for eg), accessibility might work incorrectly.
There are a few existing widgets that use platform from the theme to check:

  1. ExpansionTile:

  1. AppBar:

namesRoute: switch (theme.platform) {

  1. Dialog:

switch (theme.platform) {

namesRoute: label == null && theme.platform != TargetPlatform.iOS,

switch (theme.platform) {

namesRoute: label == null && theme.platform != TargetPlatform.iOS,

Proposal

Use defaultTargetPlatform instead of using platform from the theme.

Metadata

Metadata

Assignees

Labels

a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: proposalA detailed proposal for a change to Flutterc: tech-debtTechnical debt, code quality, testing, etc.f: material designflutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions