Skip to content

[material_ui] Migrate M3 Typography template to use new gen_defaults - #13074

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

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

Conversation

@ValentinVignal

Copy link
Copy Markdown
Contributor

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

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 Sep 30, 2026
@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Sep 30, 2026
@ValentinVignal

Copy link
Copy Markdown
Contributor Author

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

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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

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

Suggested change
expect(contents, contains('abstract final class _M3Typography'));
expect(contents, contains('abstract final class _TypographyDefaultsM3'));

@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 Sep 30, 2026

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

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?

@ValentinVignal
ValentinVignal force-pushed the material-ui/Move-typography-template-out-of-temporarily-excluded-directory branch from 8f1ec29 to 95eced6 Compare October 1, 2026 06:56

@elliette elliette left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

To keep the naming consistent, please override the className getter in the template, see main...elliette:packages:migrate-typography#diff-cd387c1377e5fd1f1de9eda3032a1ebb418be74300b8cdb0b92d595fbcc54352R18.

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.

Sure, I renamed it in Rename to _M3Typography

import 'colors.dart';
import 'text_theme.dart';

part 'generated/typography_defaults_m3.g.dart';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See suggestion below, we should keep the _M3Typography name.

}
''';

String _textTheme(String name, String baseline) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Nice! I've copied it in Use loop

@QuncCccccc QuncCccccc added the waiting for response The Flutter team cannot make further progress on this PR until the author responds label Oct 2, 2026
# 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
@ValentinVignal
ValentinVignal force-pushed the material-ui/Move-typography-template-out-of-temporarily-excluded-directory branch from 7451360 to b8e53e6 Compare October 6, 2026 06:49
@github-actions github-actions Bot removed the waiting for response The Flutter team cannot make further progress on this PR until the author responds label Oct 6, 2026

@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 for the migration:)!

@QuncCccccc QuncCccccc added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 7, 2026
@auto-submit
auto-submit Bot merged commit 05aaa04 into flutter:main Oct 7, 2026
13 checks passed
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 8, 2026
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
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
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
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.

typography_template.dart

3 participants