Skip to content

[material_ui] Migrate M3 tabs template to use new gen_defaults - #13139

Merged
auto-submit[bot] merged 7 commits into
flutter:mainfrom
ValentinVignal:material-ui/Move-tabs-template-out-of-temporarily-excluded-directory
Oct 22, 2026
Merged

auto-submit[bot] merged 7 commits into
flutter:mainfrom
ValentinVignal:material-ui/Move-tabs-template-out-of-temporarily-excluded-directory

Conversation

@ValentinVignal

Copy link
Copy Markdown
Contributor

Work toward flutter/flutter#187899.
Fixes flutter/flutter#188437

Pre-Review Checklist

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-assist bot 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

  1. 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

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Oct 6, 2026
@ValentinVignal

Copy link
Copy Markdown
Contributor Author

Like the other PRs migrating to use the new gen_defaults, this doesn't require a version and changelog

@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Oct 6, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +819 to +821
expect(contents, contains('class _TabsSecondaryDefaultsM3 extends TabBarThemeData'));
expect(contents, contains('Color? get indicatorColor => _colors.primary;'));
expect(contents, contains('Color? get labelColor => _colors.primary;'));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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;'));

@ValentinVignal
ValentinVignal force-pushed the material-ui/Move-tabs-template-out-of-temporarily-excluded-directory branch from 1126cd1 to 320e54a Compare October 6, 2026 08:46
@QuncCccccc QuncCccccc changed the title Material UI/move tabs template out of temporarily excluded directory [material_ui] move tabs template out of temporarily excluded directory Oct 6, 2026
@QuncCccccc
QuncCccccc self-requested a review October 6, 2026 21:17
@ValentinVignal

Copy link
Copy Markdown
Contributor Author

Oops, I just realised I forgot to update the title. Thank you for changing it @QuncCccccc

@QuncCccccc QuncCccccc added override: no versioning needed Override the check requiring version bumps for most changes override: no changelog needed Override the check requiring CHANGELOG updates for most changes labels Oct 8, 2026
double? get dividerHeight => ${number(TokenDivider.thickness)};

@override
Color? get indicatorColor => ${colorWithOpacity(TokenPrimaryNavigationTab.activeFocusStateLayerColor, TokenPrimaryNavigationTab.activeFocusStateLayerOpacity)};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QuncCccccc QuncCccccc changed the title [material_ui] move tabs template out of temporarily excluded directory [material_ui] Migrate M3 tabs template to use new gen_defaults Oct 8, 2026
@ValentinVignal
ValentinVignal force-pushed the material-ui/Move-tabs-template-out-of-temporarily-excluded-directory branch from 320e54a to 2287040 Compare October 13, 2026 06:59
@ValentinVignal
ValentinVignal force-pushed the material-ui/Move-tabs-template-out-of-temporarily-excluded-directory branch from 2287040 to b7ffbed Compare October 14, 2026 08:25
double? get dividerHeight => ${number(TokenDivider.thickness)};

@override
Color? get indicatorColor => ${color(TokenPrimaryNavigationTab.activeFocusStateLayerColor)};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still use a wrong token for indicatorColor.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops sorry about that, I changed it in Use correct token


@override
String generateContents(String className) =>
'''

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 => '';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in Override className :)

@ValentinVignal
ValentinVignal force-pushed the material-ui/Move-tabs-template-out-of-temporarily-excluded-directory branch from b7ffbed to ba26ea4 Compare October 15, 2026 10:33
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');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be

Suggested change
final String contents = const TabsTemplateM3().generateContents('_TabsDefaultsM3');
final String contents = const TabsTemplateM3().generateContents('');

because we intentionally override the class name.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in Update tests :)

@ValentinVignal
ValentinVignal force-pushed the material-ui/Move-tabs-template-out-of-temporarily-excluded-directory branch from ba26ea4 to 3c68004 Compare October 21, 2026 18:20

@QuncCccccc QuncCccccc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 22, 2026
@auto-submit
auto-submit Bot merged commit e0e148b into flutter:main Oct 22, 2026
13 checks passed
bkonyi pushed a commit to bkonyi/flutter that referenced this pull request Oct 23, 2026
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
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD override: no changelog needed Override the check requiring CHANGELOG updates for most changes override: no versioning needed Override the check requiring version bumps for most changes p: material_ui triage-design Should be looked at in design triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tabs_template.dart

2 participants