-
Notifications
You must be signed in to change notification settings - Fork 30.6k
Support color contrast-based theme determining #182863
Copy link
Copy link
Open
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)Owned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility teamTriaged by Framework Accessibility team
Description
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)Accessibility, e.g. VoiceOver or TalkBack. (aka a11y)c: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterf: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.team-accessibilityOwned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)Owned by Framework Accessibility team (i.e. responsible for accessibility code in flutter/flutter)triaged-accessibilityTriaged by Framework Accessibility teamTriaged by Framework Accessibility team
Type
Fields
Give feedbackNo fields configured for issues without a type.
Use case
Currently, Flutter handles accessibility contrast as a boolean value (
MediaQuery.highContrast,MaterialApp.highContrastTheme). This aligns with iOS's binary "Increase Contrast" toggle, where high contrast is either on or off.But Android supports floating-point contrast levels ranging from
-1.0to1.0(where0.0is standard,0.5is medium,1.0is high, and negative values represent lower contrast)Proposal
First, we need to implement contrast retrieval on all available platforms. Currently, contrast retrieval is implemented using the boolean value via
MediaQuery.highContrastand only on iOS (it will be available on Android after this PR is merged).Second, since
highContrastThemeonly expects a staticThemeDataobject, we need a new approach. Here are the options I came up with:A. Merge into a single theme resolver
theme: (double contrast) => ThemeData(...)B. Keep the existing theme and highContrastTheme as static ThemeData objects, but use contrast to automatically interpolate between them
C. Instead of swapping entire themes, adjust the ColorScheme dynamically based on the contrast