[material_ui] Add Material tokens (version 38.2.50) - #12471
Conversation
FolderOrigin-RevId: /google/src/cloud/elliottbrooks/update-tokens-main/google3/ux/tokens/design_systems/md/versions/latest/flutter
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
There was a problem hiding this comment.
Code Review
This pull request introduces a comprehensive set of Material 3 design token definitions under packages/material_ui/tool/gen_defaults/data/, covering components like app bars, buttons, chips, dialogs, sliders, and system tokens such as colors, motion, and typescales. Feedback on these changes suggests improving type safety and performance by defining color tokens directly as Color constants rather than String literals, representing the easingEmphasized motion curves as Cubic objects instead of strings, and changing the fontWeight property in TypescaleStruct from double to int to align with Flutter's standard representation.
|
|
||
| class TokenColorDark { | ||
| /// md.sys.color.background | ||
| static const String background = '0xFF141218'; |
There was a problem hiding this comment.
Defining colors as String literals is not ideal in Dart. This requires runtime parsing to convert them into Color objects, which is inefficient and not type-safe. It would be much better to define them as Color constants directly. You will also need to add import 'package:flutter/painting.dart'; at the top of the file.
This comment applies to all color definitions in this file and other similar color token files in this PR (color_*.dart, palette.dart).
| static const String background = '0xFF141218'; | |
| static const Color background = Color(0xFF141218); |
| static const String easingEmphasized = | ||
| 'M 0,0 C 0.05, 0, 0.133333, 0.06, 0.166666, 0.4 C 0.208333, 0.82, 0.25, 1, 1, 1'; |
There was a problem hiding this comment.
The easingEmphasized constant is defined as a String, which is inconsistent with other easing constants defined as Cubic. Using a string for an easing curve requires runtime parsing, which is inefficient. It's better to use a Curve object directly.
For Material 3's emphasized easing, the recommended implementation in Flutter is const Cubic(0.2, 0.0, 0.0, 1.0). I suggest changing the type to Cubic and using this value for consistency and performance.
static const Cubic easingEmphasized = Cubic(0.2, 0.0, 0.0, 1.0);| static const String easingEmphasized = | ||
| 'M 0,0 C 0.05, 0, 0.133333, 0.06, 0.166666, 0.4 C 0.208333, 0.82, 0.25, 1, 1, 1'; |
There was a problem hiding this comment.
The easingEmphasized constant is defined as a String, which is inconsistent with other easing constants defined as Cubic. Using a string for an easing curve requires runtime parsing, which is inefficient. It's better to use a Curve object directly.
For Material 3's emphasized easing, the recommended implementation in Flutter is const Cubic(0.2, 0.0, 0.0, 1.0). I suggest changing the type to Cubic and using this value for consistency and performance.
static const Cubic easingEmphasized = Cubic(0.2, 0.0, 0.0, 1.0);| final String name; | ||
| final String fontFamily; | ||
| final double fontSize; | ||
| final double fontWeight; |
There was a problem hiding this comment.
The fontWeight property should be of type int instead of double. In Flutter's TextStyle, fontWeight is represented by FontWeight constants, which have integer values (e.g., 400 for normal, 700 for bold). Using double is semantically incorrect for this property.
| final double fontWeight; | |
| final int fontWeight; |
QuncCccccc
left a comment
There was a problem hiding this comment.
LGTM!
The PR description shows 2 Pre-Review Checklist sets=)
Export the Material tokens to
material_ui. This PR simply exports the existing tokens from g3 to Github.Work towards flutter/flutter#186906
Pre-Review Checklist
[shared_preferences]///).Test exemption: All generated code.
If you need help, consider asking for advice on the #hackers-new channel on [Discord].
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2