[material_ui] Add all M3 templates and generated code to temporarily_excluded/ before migration - #12661
Conversation
…_excluded/` before migration (flutter#12206)
There was a problem hiding this comment.
Code Review
This pull request introduces a large set of generated Material 3 defaults and corresponding templates under a temporarily excluded directory, along with an exclusion rule in analysis_options.yaml. The feedback highlights several runtime safety issues where token values are cast directly to double. Since these values can be parsed as int from JSON, the reviewer recommends casting them to num first in motion_template.dart, typography_template.dart, and input_decorator_template.dart to prevent potential TypeError exceptions.
| (MapEntry<String, dynamic> a, MapEntry<String, dynamic> b) => | ||
| (a.value as double).compareTo(b.value as double), |
There was a problem hiding this comment.
Casting a.value directly to double will throw a TypeError at runtime if the value is parsed as an int (which is common for whole numbers in JSON). Casting to num instead is safer and supports both int and double values.
| (MapEntry<String, dynamic> a, MapEntry<String, dynamic> b) => | |
| (a.value as double).compareTo(b.value as double), | |
| (MapEntry<String, dynamic> a, MapEntry<String, dynamic> b) => | |
| (a.value as num).compareTo(b.value as num), |
| String durationTokenString(String token, dynamic tokenValue) { | ||
| tokensLogger.log(token); | ||
| final String tokenName = token.split('.').last.replaceAll('-', '').replaceFirst('Ms', ''); | ||
| final int milliseconds = (tokenValue as double).toInt(); |
There was a problem hiding this comment.
Casting tokenValue directly to double will throw a TypeError at runtime if the value is parsed as an int. Casting to num before calling toInt() is safer and supports both int and double values.
| final int milliseconds = (tokenValue as double).toInt(); | |
| final int milliseconds = (tokenValue as num).toInt(); |
| final size = getToken('$textStyleTokenName.size') as double; | ||
| final lineHeight = getToken('$textStyleTokenName.line-height') as double; |
There was a problem hiding this comment.
Casting the token values directly to double will throw a TypeError at runtime if they are parsed as int (e.g., whole numbers like 12 or 16). Casting to num and calling toDouble() is safer and supports both int and double values.
| final size = getToken('$textStyleTokenName.size') as double; | |
| final lineHeight = getToken('$textStyleTokenName.line-height') as double; | |
| final double size = (getToken('$textStyleTokenName.size') as num).toDouble(); | |
| final double lineHeight = (getToken('$textStyleTokenName.line-height') as num).toDouble(); |
| final width = | ||
| (getToken('$componentToken1.width', optional: true) ?? | ||
| getToken('$componentToken1.height', optional: true) ?? | ||
| getToken('$componentToken2.width', optional: true) ?? | ||
| getToken('$componentToken2.height', optional: true) ?? | ||
| 1.0) | ||
| as double; |
There was a problem hiding this comment.
Casting the width/height token value directly to double will throw a TypeError at runtime if the value is parsed as an int. Casting to num and calling toDouble() is safer and supports both int and double values.
| final width = | |
| (getToken('$componentToken1.width', optional: true) ?? | |
| getToken('$componentToken1.height', optional: true) ?? | |
| getToken('$componentToken2.width', optional: true) ?? | |
| getToken('$componentToken2.height', optional: true) ?? | |
| 1.0) | |
| as double; | |
| final double width = | |
| ((getToken('$componentToken1.width', optional: true) ?? | |
| getToken('$componentToken1.height', optional: true) ?? | |
| getToken('$componentToken2.width', optional: true) ?? | |
| getToken('$componentToken2.height', optional: true) ?? | |
| 1.0) as num).toDouble(); |
QuncCccccc
left a comment
There was a problem hiding this comment.
LGTM! Thanks for porting it over!
Just to double check, we don't need CHANGELOG entries for any gen_defaults changes right?
Nope, as long as all the changes are in |
…er#191965) flutter/packages@bd3cbc1...cd4cdd0 2026-08-28 21270878+elliette@users.noreply.github.com [material_ui] Add all M3 templates and generated code to `temporarily_excluded/` before migration (flutter/packages#12661) 2026-08-28 engine-flutter-autoroll@skia.org Roll Flutter from 15d8908 to e8dca90 (58 revisions) (flutter/packages#12660) 2026-08-28 bkonyi@google.com [various] Update pigeon dev_dependency to ^27.3.2 (flutter/packages#12615) 2026-08-27 269567208+reidbaker-agent@users.noreply.github.com [camera_android_camerax] Enforce CHANGELOG backticks and add eval commit author check to pre-push-skill (flutter/packages#12624) 2026-08-27 imcusg@gmail.com [material_ui] Prevent stale async suggestions in SearchAnchor (flutter/packages#12478) 2026-08-27 bkonyi@google.com [go_router_builder] Support analyzer 14 (flutter/packages#12614) 2026-08-27 srawlins@google.com [cupertino_ui] Use super parameters in more places (flutter/packages#12459) 2026-08-27 32538273+ValentinVignal@users.noreply.github.com [material_ui] Remove no-shuffle from progress indicator test (flutter/packages#12505) 2026-08-27 32538273+ValentinVignal@users.noreply.github.com [two_dimensional_scrollables] Activate leak testing and fix memory leaks (flutter/packages#11653) 2026-08-27 21270878+elliette@users.noreply.github.com [material_ui] Add helper methods in gen_defaults template (flutter/packages#12637) 2026-08-27 brackenavaron@gmail.com [cupertino_ui] fix CupertinoIcons font not being included in examples and fix TextEditingController leaks (flutter/packages#12228) 2026-08-27 269567208+reidbaker-agent@users.noreply.github.com [camera_android_camerax] Check Git hooks configuration in check-readiness skill (flutter/packages#12628) 2026-08-27 47866232+chunhtai@users.noreply.github.com [ci] sync back pr for branch release only run when release succeeds (flutter/packages#12581) 2026-08-27 stuartmorgan@google.com [google_maps_flutter] Convert overlay controllers to Swift (flutter/packages#12638) 2026-08-27 47866232+chunhtai@users.noreply.github.com [go_router_builder] Fixes text golden test to ignore platform specific newline (flutter/packages#12652) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com 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 towards flutter/flutter#191088
Ports over #12206 which landed on the
m3e_migrationfeature branch.Original PR description
Work towards flutter/flutter#187899
Moves all M3 templates and their generated code to gen_defaults/temporarily_excluded before we begin migrating.
This way when we migrate each component, we can first move the template and its respective generated code into the new directories, edit the template, and re-generate the code. This will make it easier to review changes to the templates and validate the generated output.
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