[material_ui] Add contrastLevel for M3 ColorScheme - #11801
Conversation
129b42b to
c410028
Compare
de5b083 to
6d663fa
Compare
8ce2d9e to
4513c4f
Compare
4513c4f to
e293b35
Compare
| stdout.writeln('Generating contents...'); | ||
| } | ||
| final String contents = generateContents(_className); | ||
| final String contents = generateContents(requiresGeneratedClass ? _className : ''); |
There was a problem hiding this comment.
We don't need a class for ColorScheme, so I added a requiresGeneratedClass field.
There was a problem hiding this comment.
Code Review
This pull request introduces support for Material 3 contrast levels in ThemeData by adding a contrastLevel parameter to the constructor. This allows standard, medium, high, or custom contrast levels to be applied when generating or selecting a ColorScheme. The generation of default color schemes is migrated to a new template (ColorSchemeTemplateM3), and corresponding unit tests are added. Feedback on the changes points out a broken documentation link referencing a non-existent public ThemeData.contrastLevel property, suggesting it be updated to refer to the constructor parameter instead.
| /// A custom `double` between -1.0 and 1.0 can also be passed to | ||
| /// [ThemeData.contrastLevel] when [ThemeData.colorSchemeSeed] is provided, in | ||
| /// which case the value is passed to [ColorScheme.fromSeed]. |
There was a problem hiding this comment.
The documentation references [ThemeData.contrastLevel], but ThemeData does not actually have a public contrastLevel property or getter (similar to colorSchemeSeed). This results in a broken documentation link. We should update the documentation to refer to the constructor parameter instead.
/// A custom double between -1.0 and 1.0 can also be passed as the
/// contrastLevel parameter of the [ThemeData] constructor when
/// [ThemeData.colorSchemeSeed] is provided, in which case the value is passed
/// to [ColorScheme.fromSeed].There was a problem hiding this comment.
Updated documentation.
Fixes flutter/flutter#184951
This PR is to add medium- and high-contrast M3 ColorScheme baselines. I also added a
double? contrastLeveltoThemeData.By default,
ThemeData()shows standard M3 ColorScheme. To choose medium/high contrast, useThis change will not cause breaking changes because the standard-contrast m3 color scheme baseline stays the same.
TODO:
Add an example or update an existing example to reflect the new feature.
Pre-Review Checklist
[shared_preferences]///).