-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Fix #117755: Fix divider color inconsistencies in M2/M3 #178826
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request addresses an inconsistency in the dividerColor for Material 2 and Material 3 themes in Flutter. The changes ensure that ThemeData.dividerColor uses colorScheme.outlineVariant for M3 themes, as per the Material Design specification, across different ThemeData constructors. The M2 behavior is preserved. The pull request also includes a comprehensive set of tests to verify this consistency. The changes are correct and well-tested, but I have one suggestion to improve the robustness of one of the new tests.
98b18eb to
d9f760a
Compare
Updated ThemeData constructors to use correct divider colors per Material Design specifications: - M2: onSurface.withOpacity(0.12) - M3: outlineVariant This ensures Theme.dividerColor matches actual Divider widget color and eliminates confusion between theme creation methods. The issue was that ThemeData.dividerColor returned different values depending on how the theme was created: - ThemeData() with M3 returned 'outline' (incorrect) - ThemeData.from() with M3 returned 'onSurface.withOpacity(0.12)' (M2 value, incorrect) - Divider widget always used 'outlineVariant' in M3 (correct) Now all theme creation methods return the correct dividerColor that matches what the Divider widget actually renders. Fixes flutter#117755
d9f760a to
7c5c1d3
Compare
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Piinks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @777genius thanks for contributing!
It looks like this is currently failing several tests and the analyzer, can you take a look?
Also, do you have a reference to these being the right value in the material spec? I noticed the original issue is a few years old, and it may have changed since then.
cc @QuncCccccc who may know. :)
Description
This PR fixes
ThemeData.dividerColorto return the correct color that matches what theDividerwidget actually renders in Material 2 and Material 3.Problem
ThemeData.dividerColorreturned different values depending on how the theme was created, causing inconsistency with the actualDividerwidget color:ThemeData()with M3 returnedoutlineinstead ofoutlineVariantThemeData.from()with M3 returned M2 valueonSurface.withOpacity(0.12)instead of M3 valueoutlineVariantDividerwidget always correctly usedoutlineVariantin M3This created confusion for developers who expected
Theme.of(context).dividerColorto match the actual divider color they saw on screen.Solution
Updated both
ThemeData()andThemeData.from()constructors to use the correct divider colors per Material Design specifications:ColorScheme.onSurface.withOpacity(0.12)(unchanged)ColorScheme.outlineVariant(fixed)Now all theme creation methods return the correct
dividerColorthat matches what theDividerwidget actually renders.Testing
Added 4 comprehensive tests that verify:
dividerColorequalsoutlineVariantfor all theme creation methodsdividerColormatches actualDividerwidget colordividerColorequalsonSurface.withOpacity(0.12)and matches actualDividerwidget colorRelated Issues
Fixes #117755
Pre-launch Checklist
///).