gen_defaults should follow new versioning strategy#11918
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the token template generation tool to support both Material 3 and Material 3 Expressive defaults. It introduces a public TokenTemplate class, dynamically generates class names based on the Material version, and adds assertions to ensure the generated contents define the expected class. The tests have been updated to cover both template types. Feedback suggests handling underscores in template names when generating class names to ensure they strictly adhere to the Dart UpperCamelCase style guide.
There was a problem hiding this comment.
Code Review
This pull request refactors the TokenTemplate class to standardize template naming conventions using spaced, capitalized words, and automatically derives output filenames and class names for Material 3 and Material 3 Expressive defaults. It also adds assertions to validate the generated class names and template name formats, and updates the corresponding tests and test fixtures. Feedback on the pull request points out that using parentName in the part of directive will generate an invalid filename containing spaces and capitalization, and suggests using $snakeName.dart instead.
Work towards flutter/flutter#186906
Work towards flutter/flutter#187899
Previously, the
gen_defaultsscript generated the files in different directories based on whether or not the template was an M3 or M3E template. Since we are planning on using an variant enum instead of different libraries to separate M3 and M3E implementations, thegen_defaultsscript needs to be accordingly updated.Before:
After:
The template now creates the generated class name as well, either
M3NameDefaultsorM3ENameDefaults(e.g.M3EButtonDefaults).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