Repository navigation
[material_ui] Migrate M3 Typography template to use new gen_defaults - #13074
Conversation
|
I guess, like the other PRs migrating to use the new gen_defaults, this doesn't require a version and changelog |
There was a problem hiding this comment.
Code Review
This pull request migrates the Material 3 typography defaults generation to a dedicated template (TypographyTemplateM3) and outputs them to a generated file (typography_defaults_m3.g.dart), which is then included as a part of typography.dart. Feedback on these changes highlights two critical issues: first, typography.dart still references the old _M3Typography class name instead of the renamed _TypographyDefaultsM3, which will cause compilation errors; second, the newly added test in gen_defaults_test.dart incorrectly asserts the presence of the old class name and needs to be updated to match the new class name.
| import 'colors.dart'; | ||
| import 'text_theme.dart'; | ||
|
|
||
| part 'generated/typography_defaults_m3.g.dart'; |
There was a problem hiding this comment.
The generated class name has been changed from _M3Typography to _TypographyDefaultsM3 in typography_defaults_m3.g.dart. However, typography.dart still references _M3Typography (for example, at line 2086: static const TextTheme tall2021 = _M3Typography.tall;, and likely for englishLike2021 and dense2021 as well). This will cause compilation errors. Please update all references in typography.dart to use _TypographyDefaultsM3 instead of _M3Typography.
There was a problem hiding this comment.
See suggestion below, we should keep the _M3Typography name.
| // https://github.com/flutter/flutter/issues/187899 | ||
| const template = TypographyTemplateM3(); | ||
| final String contents = _generateContents(template); | ||
| expect(contents, contains('abstract final class _M3Typography')); |
There was a problem hiding this comment.
The test expects the generated class to be named _M3Typography, but the new TypographyTemplateM3 generates _TypographyDefaultsM3 (as seen in the generated file). This will cause the test to fail. Please update the assertion to expect _TypographyDefaultsM3.
| expect(contents, contains('abstract final class _M3Typography')); | |
| expect(contents, contains('abstract final class _TypographyDefaultsM3')); |
QuncCccccc
left a comment
There was a problem hiding this comment.
I guess, like the other PRs migrating to use the new gen_defaults, this doesn't require a version and changelog
Yes! I added the no version and no changelog label. Thanks a lot for your contribution!
I noticed this PR has some non-trypography change. We might want to revert them. Also could you help fixing all the test failures?
8f1ec29 to
95eced6
Compare
elliette
left a comment
There was a problem hiding this comment.
Thank you! Was about to open a PR for this then saw you had gotten to it first 😄 Left a couple comments but overall looks good!
| /// The Material Design 3 specification does not include 'dense' text themes, | ||
| /// so this is just here to be consistent with the API. | ||
| static const TextTheme dense2021 = _M3Typography.dense; | ||
| static const TextTheme dense2021 = _TypographyDefaultsM3.dense; |
There was a problem hiding this comment.
To keep the naming consistent, please override the className getter in the template, see main...elliette:packages:migrate-typography#diff-cd387c1377e5fd1f1de9eda3032a1ebb418be74300b8cdb0b92d595fbcc54352R18.
There was a problem hiding this comment.
Sure, I renamed it in Rename to _M3Typography
| import 'colors.dart'; | ||
| import 'text_theme.dart'; | ||
|
|
||
| part 'generated/typography_defaults_m3.g.dart'; |
There was a problem hiding this comment.
See suggestion below, we should keep the _M3Typography name.
| } | ||
| '''; | ||
|
|
||
| String _textTheme(String name, String baseline) { |
There was a problem hiding this comment.
We can do this in a loop, see example in main...elliette:packages:migrate-typography#diff-cd387c1377e5fd1f1de9eda3032a1ebb418be74300b8cdb0b92d595fbcc54352R53
# Conflicts: # packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart # packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart # Conflicts: # packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart # packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart
7451360 to
b8e53e6
Compare
QuncCccccc
left a comment
There was a problem hiding this comment.
LGTM. Thank you for the migration:)!
flutter/packages@7660d46...54706bd 2026-10-08 [email protected] [image_picker_ios] Return an error for undecodable image data (flutter/packages#12267) 2026-10-07 [email protected] [flutter shaders] update min flutter version (flutter/packages#13160) 2026-10-07 [email protected] Import flutter_shaders package (flutter/packages#12583) 2026-10-07 [email protected] [material_ui] Migrate M3 Typography template to use new gen_defaults (flutter/packages#13074) 2026-10-07 [email protected] Sync release-material_ui-1.6.0 to main (flutter/packages#13149) 2026-10-07 [email protected] [pigeon] Fix native interop (JNI) calls in minified Android release builds (flutter/packages#13151) 2026-10-06 [email protected] [material_ui] Migrate ListTile and SwitchListTile API doc snippets to {@example} (batch 10) (flutter/packages#13097) 2026-10-06 [email protected] Sync release-cupertino_ui-1.1.2 to main (flutter/packages#13150) 2026-10-06 [email protected] [material_ui] Fix `TabBar` assertion to allow `indicatorWeight: 0` with a themed `indicator` (flutter/packages#12696) 2026-10-06 [email protected] [material_ui] Fix time picker input validation for 24-hour locales (flutter/packages#13033) 2026-10-06 [email protected] [material_ui] Migrate Checkbox, CheckboxListTile, Radio, and RadioListTile API doc snippets to {@example} (batch 9) (flutter/packages#13112) 2026-10-06 [email protected] [quick_actions_android] Return null from getLaunchAction when no activity is attached (flutter/packages#12331) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@7660d46...54706bd 2026-10-08 [email protected] [image_picker_ios] Return an error for undecodable image data (flutter/packages#12267) 2026-10-07 [email protected] [flutter shaders] update min flutter version (flutter/packages#13160) 2026-10-07 [email protected] Import flutter_shaders package (flutter/packages#12583) 2026-10-07 [email protected] [material_ui] Migrate M3 Typography template to use new gen_defaults (flutter/packages#13074) 2026-10-07 [email protected] Sync release-material_ui-1.6.0 to main (flutter/packages#13149) 2026-10-07 [email protected] [pigeon] Fix native interop (JNI) calls in minified Android release builds (flutter/packages#13151) 2026-10-06 [email protected] [material_ui] Migrate ListTile and SwitchListTile API doc snippets to {@example} (batch 10) (flutter/packages#13097) 2026-10-06 [email protected] Sync release-cupertino_ui-1.1.2 to main (flutter/packages#13150) 2026-10-06 [email protected] [material_ui] Fix `TabBar` assertion to allow `indicatorWeight: 0` with a themed `indicator` (flutter/packages#12696) 2026-10-06 [email protected] [material_ui] Fix time picker input validation for 24-hour locales (flutter/packages#13033) 2026-10-06 [email protected] [material_ui] Migrate Checkbox, CheckboxListTile, Radio, and RadioListTile API doc snippets to {@example} (batch 9) (flutter/packages#13112) 2026-10-06 [email protected] [quick_actions_android] Return null from getLaunchAction when no activity is attached (flutter/packages#12331) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Work toward flutter/flutter#187899.
Fixes flutter/flutter#188440
Pre-Review Checklist
[shared_preferences]///).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