Repository navigation
[material_ui] Migrate M3 tabs template to use new gen_defaults - #13139
Conversation
|
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 generation of Material 3 Tabs defaults to the new token-based generator (TabsTemplateM3), moving the generated code into a separate part file (tabs_defaults_m3.g.dart) and enabling the generator in gen_defaults.dart along with its corresponding tests. A review comment points out an incorrect assertion in the newly added tests for _TabsSecondaryDefaultsM3's labelColor, which should expect _colors.onSurface instead of _colors.primary.
| expect(contents, contains('class _TabsSecondaryDefaultsM3 extends TabBarThemeData')); | ||
| expect(contents, contains('Color? get indicatorColor => _colors.primary;')); | ||
| expect(contents, contains('Color? get labelColor => _colors.primary;')); |
There was a problem hiding this comment.
The assertion for _TabsSecondaryDefaultsM3's labelColor is copy-pasted from _TabsPrimaryDefaultsM3 and expects _colors.primary. However, in _TabsSecondaryDefaultsM3, the active label color is mapped to TokenSecondaryNavigationTab.activeLabelTextColor, which resolves to _colors.onSurface. This assertion should be updated to expect _colors.onSurface to avoid test failures.
| expect(contents, contains('class _TabsSecondaryDefaultsM3 extends TabBarThemeData')); | |
| expect(contents, contains('Color? get indicatorColor => _colors.primary;')); | |
| expect(contents, contains('Color? get labelColor => _colors.primary;')); | |
| expect(contents, contains('class _TabsSecondaryDefaultsM3 extends TabBarThemeData')); | |
| expect(contents, contains('Color? get indicatorColor => _colors.primary;')); | |
| expect(contents, contains('Color? get labelColor => _colors.onSurface;')); |
1126cd1 to
320e54a
Compare
|
Oops, I just realised I forgot to update the title. Thank you for changing it @QuncCccccc |
| double? get dividerHeight => ${number(TokenDivider.thickness)}; | ||
|
|
||
| @override | ||
| Color? get indicatorColor => ${colorWithOpacity(TokenPrimaryNavigationTab.activeFocusStateLayerColor, TokenPrimaryNavigationTab.activeFocusStateLayerOpacity)}; |
There was a problem hiding this comment.
I don't think this is correct; indicatorColor should just have colorScheme.primary instead of having opacity.
It is a bit weird that the generated tabs_defaults_m3.g.dart doesn't show any diff. Once this is fixed, could you try to run the gen_defaults script and verify whether the template can generate correct defaults?
There was a problem hiding this comment.
Sure, I fixed it in Don't use opacity for indicator color
320e54a to
2287040
Compare
2287040 to
b7ffbed
Compare
| double? get dividerHeight => ${number(TokenDivider.thickness)}; | ||
|
|
||
| @override | ||
| Color? get indicatorColor => ${color(TokenPrimaryNavigationTab.activeFocusStateLayerColor)}; |
There was a problem hiding this comment.
We still use a wrong token for indicatorColor.
There was a problem hiding this comment.
Oops sorry about that, I changed it in Use correct token
|
|
||
| @override | ||
| String generateContents(String className) => | ||
| ''' |
There was a problem hiding this comment.
Running the generator with asserts enabled (dart --enable-asserts tool/gen_defaults/bin/gen_defaults.dart) fails with "The generated contents for "Tabs" must define the class "_TabsDefaultsM3"". Since this template generates two classes, we can override className to be empty, like:
@override
String get className => '';b7ffbed to
ba26ea4
Compare
| test('TabsTemplateM3 emits M3 Tabs defaults from tokens', () { | ||
| // Intentionally empty, will be implemented during migration. See: | ||
| // https://github.com/flutter/flutter/issues/187899 | ||
| final String contents = const TabsTemplateM3().generateContents('_TabsDefaultsM3'); |
There was a problem hiding this comment.
It should be
| final String contents = const TabsTemplateM3().generateContents('_TabsDefaultsM3'); | |
| final String contents = const TabsTemplateM3().generateContents(''); |
because we intentionally override the class name.
# Conflicts: # packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart
ba26ea4 to
3c68004
Compare
flutter/packages@93baed9...108dad0 2026-10-22 [email protected] [material_ui] Migrate M3 IconButton template to use new gen_defaults (flutter/packages#12922) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationBar template to use new gen_defaults (flutter/packages#13067) 2026-10-22 [email protected] [material_ui] Remove obsolete `SurfaceTint` defaults template (flutter/packages#13276) 2026-10-22 [email protected] [material_ui] Migrate M3 Radio template to use new gen_defaults (flutter/packages#13210) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationDrawer template to use new gen_defaults (flutter/packages#13068) 2026-10-22 [email protected] [image_picker_ios] PR 3/5 Split SPM packaging and migrate the plugin class to Swift (flutter/packages#13235) 2026-10-22 [email protected] [ci] Increase check-discovery timeout in release workflows (flutter/packages#13392) 2026-10-22 [email protected] [material_ui] Migrate M3 `Switch` template to use new gen_defaults (flutter/packages#13274) 2026-10-22 [email protected] [material_ui] Migrate M3 PopupMenu template to use new gen_defaults (flutter/packages#13209) 2026-10-22 [email protected] [material_ui] Add day and weekday builders to CalendarDatePicker and showDatePicker (flutter/packages#12587) 2026-10-22 [email protected] [material_ui] Migrate M3 `SearchView` template to use new gen_defaults (flutter/packages#13272) 2026-10-22 [email protected] [material_ui] Migrate M3 `TextField` template to use new gen_defaults (flutter/packages#13275) 2026-10-22 [email protected] [material_ui] Migrate M3 RangeSlider template to use new gen_defaults (flutter/packages#13215) 2026-10-22 [email protected] [go_router] Keep web autocomplete focused in shell routes (flutter/packages#13348) 2026-10-22 [email protected] [shared_preferences_android] Fix web compilation of apps that import the package (flutter/packages#13380) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationRail template to use new gen_defaults (flutter/packages#13069) 2026-10-22 [email protected] [material_ui] Migrate M3 SearchBar template to use new gen_defaults (flutter/packages#13216) 2026-10-22 [email protected] [material_ui] Fix for time picker error in locales that do not use Latin digits (flutter/packages#13035) 2026-10-22 [email protected] [material_ui] Fix MenuAnchor scrollbar safe-area padding (flutter/packages#12470) 2026-10-22 [email protected] [material_ui] Document Material 3 fallback for Divider.color and VerticalDivider.color (flutter/packages#12967) 2026-10-22 [email protected] [material_ui] Migrate M3 tabs template to use new gen_defaults (flutter/packages#13139) 2026-10-22 [email protected] [material_ui] Migrate M3 progress indicator defaults to new gen_defaults (flutter/packages#13026) 2026-10-22 [email protected] [google_sign_in] Convert the iOS example app and UI tests to Swift (flutter/packages#13271) 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@93baed9...108dad0 2026-10-22 [email protected] [material_ui] Migrate M3 IconButton template to use new gen_defaults (flutter/packages#12922) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationBar template to use new gen_defaults (flutter/packages#13067) 2026-10-22 [email protected] [material_ui] Remove obsolete `SurfaceTint` defaults template (flutter/packages#13276) 2026-10-22 [email protected] [material_ui] Migrate M3 Radio template to use new gen_defaults (flutter/packages#13210) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationDrawer template to use new gen_defaults (flutter/packages#13068) 2026-10-22 [email protected] [image_picker_ios] PR 3/5 Split SPM packaging and migrate the plugin class to Swift (flutter/packages#13235) 2026-10-22 [email protected] [ci] Increase check-discovery timeout in release workflows (flutter/packages#13392) 2026-10-22 [email protected] [material_ui] Migrate M3 `Switch` template to use new gen_defaults (flutter/packages#13274) 2026-10-22 [email protected] [material_ui] Migrate M3 PopupMenu template to use new gen_defaults (flutter/packages#13209) 2026-10-22 [email protected] [material_ui] Add day and weekday builders to CalendarDatePicker and showDatePicker (flutter/packages#12587) 2026-10-22 [email protected] [material_ui] Migrate M3 `SearchView` template to use new gen_defaults (flutter/packages#13272) 2026-10-22 [email protected] [material_ui] Migrate M3 `TextField` template to use new gen_defaults (flutter/packages#13275) 2026-10-22 [email protected] [material_ui] Migrate M3 RangeSlider template to use new gen_defaults (flutter/packages#13215) 2026-10-22 [email protected] [go_router] Keep web autocomplete focused in shell routes (flutter/packages#13348) 2026-10-22 [email protected] [shared_preferences_android] Fix web compilation of apps that import the package (flutter/packages#13380) 2026-10-22 [email protected] [material_ui] Migrate M3 NavigationRail template to use new gen_defaults (flutter/packages#13069) 2026-10-22 [email protected] [material_ui] Migrate M3 SearchBar template to use new gen_defaults (flutter/packages#13216) 2026-10-22 [email protected] [material_ui] Fix for time picker error in locales that do not use Latin digits (flutter/packages#13035) 2026-10-22 [email protected] [material_ui] Fix MenuAnchor scrollbar safe-area padding (flutter/packages#12470) 2026-10-22 [email protected] [material_ui] Document Material 3 fallback for Divider.color and VerticalDivider.color (flutter/packages#12967) 2026-10-22 [email protected] [material_ui] Migrate M3 tabs template to use new gen_defaults (flutter/packages#13139) 2026-10-22 [email protected] [material_ui] Migrate M3 progress indicator defaults to new gen_defaults (flutter/packages#13026) 2026-10-22 [email protected] [google_sign_in] Convert the iOS example app and UI tests to Swift (flutter/packages#13271) 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#188437
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