Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix Color Scheme Defaults in Material 3 #112666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 28, 2022

Conversation

QuncCccccc
Copy link
Contributor

@QuncCccccc QuncCccccc commented Sep 29, 2022

Fixes: #111520

This PR is to create a default light color scheme and a default dark color scheme for ThemeData when the ThemeData.useMaterial3 is set to be true.

To get a M3 light color scheme without setting a seed color, use ThemeData(useMaterial3: true), or ThemeData.light(useMaterial3: true).
To get a M3 dark color scheme, use ThemeData(useMaterial3: true, brightness: Brightness.dark), or ThemeData.dark(useMaterial3: true).
Screen Shot 2022-09-29 at 2 39 01 PMScreen Shot 2022-09-29 at 2 39 18 PM

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. c: contributor-productivity Team-specific productivity, code health, technical debt. labels Sep 29, 2022
@QuncCccccc QuncCccccc changed the title Fix color scheme defaults m3 Fix Color Scheme Defaults in Material 3 Sep 29, 2022
@QuncCccccc QuncCccccc marked this pull request as ready for review September 29, 2022 23:18
@flutter-dashboard
Copy link

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #112666 at sha a3e0252a1784d3ad4e4b63d5d6669def71faa3c8

@flutter-dashboard flutter-dashboard bot added the will affect goldens Changes to golden files label Sep 29, 2022
@QuncCccccc
Copy link
Contributor Author

Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change).

If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

Changes reported for pull request #112666 at sha a3e0252

Marked them as positive because the surface color changes a little after we use the default m3 ColorScheme

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @QuncCccccc. Just a couple of small issues to be resolved and I need to think more about whether we want to try and address #107105 at the same time.

inverseSurface: Color(${tokens[colorTokensDark['md.sys.color.inverse-surface']]}),
onInverseSurface: Color(${tokens[colorTokensDark['md.sys.color.inverse-on-surface']]}),
inversePrimary: Color(${tokens[colorTokensDark['md.sys.color.inverse-primary']]}),
surfaceTint: Color(${tokens[colorTokensDark['md.sys.color.primary']]}),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here?

Copy link
Contributor

@darrenaustin darrenaustin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think this does address the issue in #107105 at least for the case where they have specified useMaterial3: true, it will get the same results whether they create the color scheme with a seed in ThemeData or via ColorScheme.fromSeed. It doesn't fix the case where useMaterial3 is false, but I think that is ok for now.

LTGM. Thx and sorry for the delay on this.

We might want to advertise this change in discord to make sure people are aware that the default M3 color schemes will be changed with this PR. Speaking of which, can we add something to the useMaterial3 flag's docs that describes this new behaviour? Or perhaps something in the constructor for ThemeData?

@QuncCccccc QuncCccccc force-pushed the fix_color_scheme_defaults_m3 branch from 2031356 to 3743b9d Compare October 27, 2022 18:05
/// use new colors, typography and other features of Material 3. A new
/// purple-based [ColorScheme] will be created and applied to the updated
/// widgets, as long as this is set to true. If false, they will use the
/// Material 2 look and feel.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@darrenaustin Thanks a lot for the suggestions! I just added a comment here. Does this look okay? Wondering if I should add more details.

@rydmike
Copy link
Contributor

rydmike commented Jan 7, 2023

@darrenaustin and @QuncCccccc I agree that this merge improves the situation in Material 3, and I do like the new M3 default scheme. However, it does not completely fix the difference between ThemeData, ThemeData.from and ThemeData(colorSchemeSeed) even in Material 3.

Yes the ColorSchemes are now the same in M3 (hooray), but you still get differences in old ThemeData.dividerColor when using ThemeData factory versus ThemeData.from, that causes some minor differences in style, also in M3. This can be tested and seen in the demo app in this issue #117755, that also proposes minor changes to fix this in M3 and keep as is in M2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c: contributor-productivity Team-specific productivity, code health, technical debt. f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. will affect goldens Changes to golden files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ThemeData.light()/ThemeData.dark() in M3 doesn't generate correct colors for some components.
3 participants