Skip to content

[material_ui] Refactor typography.dart and text_theme.dart in preparation for M3E - #13371

Merged
auto-submit[bot] merged 6 commits into
flutter:mainfrom
elliette:typography-refactor
Oct 27, 2026
Merged

auto-submit[bot] merged 6 commits into
flutter:mainfrom
elliette:typography-refactor

Conversation

@elliette

@elliette elliette commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

This PR is a no-op refactor of typography.dart and text_theme.dart to prepare for the Material 3 Expressive text styles. These changes were split out from my larger M3E typography changes to prevent that PR from being too big.

Specifically, this PR:

  • uses dartdoc templates in the TextTheme documentation to reduce documentation duplication
  • uses a helper method inside apply to reduce code duplication (helpful since we will be adding 15 new text styles with M3E)
  • adds a similar helper method inside merge to reduce code duplication
  • adds a _withM3Colors factory constructor to Typography. Currently this is only used once for M3, but it will also be used for M3E.

The tests in this PR are purely to increase coverage since these changes are all no-ops. They are not regression tests.

Fixes flutter/flutter#195011

Pre-Review Checklist

Version and changelog exemption: Purely a refactor, no user-noticeable changes.

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 21, 2026
@github-actions github-actions Bot added p: material_ui triage-design Should be looked at in design triage labels Oct 21, 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 refactors TextTheme by introducing template and macro documentation tags to reduce comment duplication, and simplifies the apply method using a local helper function. It also refactors Typography.material2021 to delegate to a new _withM3Colors factory constructor, and reorganizes and expands the test suites for both classes. Feedback on the changes indicates that an assertion verifying the platform or text themes was omitted during the typography refactoring and should be restored.

@elliette elliette 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 22, 2026
@elliette
elliette requested a review from QuncCccccc October 22, 2026 16:23
@elliette
elliette force-pushed the typography-refactor branch from 22c5574 to f7b4c49 Compare October 26, 2026 17:23

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


/// Largest of the display styles.
///
/// {@template material_ui.TextTheme.displayStyle}

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 have a strong opinion about {@macro} but I remember Ian once pointed out that {@macro} makes docs hard to read inline and easy to get wrong when a template is edited later (flutter/flutter#142516 (comment)
). These docs look short and clear, so I'd lean slightly towards keeping the inline docs. But either way is fine to me:)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That makes sense! I've removed the {@macro} templates

@elliette
elliette force-pushed the typography-refactor branch from f7b4c49 to 2bcc9e7 Compare October 27, 2026 17:00
@elliette elliette added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2026
@auto-submit
auto-submit Bot merged commit 727c73e into flutter:main Oct 27, 2026
13 checks passed
flutter-zl pushed a commit to flutter-zl/flutter that referenced this pull request Oct 28, 2026
flutter/packages@a8549ae...13d38e0

2026-10-28 [email protected] [material_ui] Unskip long press drag test
on web (flutter/packages#13358)
2026-10-28 [email protected] [google_maps_flutter_ios, pigeon,
webview_flutter_wkwebview] Migrate remaining example apps to uiscene
(flutter/packages#13280)
2026-10-27 [email protected] manually roll flutter and fix flaky
video player test that is preventing roll from landing
(flutter/packages#13465)
2026-10-27 [email protected] [material_ui]
Unskip web tests that pass on CanvasKit and Skwasm: data_table_test,
floating_action_button_test, text_field_cursor_test
(flutter/packages#13460)
2026-10-27 [email protected] [material_ui] Decouple
disabled CheckboxListTile state in a11y_assessments
(flutter/packages#13177)
2026-10-27 [email protected] [camera_web] Skip video input
devices that cannot be started in availableCameras
(flutter/packages#13196)
2026-10-27 [email protected] [camera] Add support for
zero-shutter-lag capture (flutter/packages#12374)
2026-10-27 [email protected] [in_app_purchase_storekit} Fix more test
flakes (flutter/packages#13279)
2026-10-27 [email protected] [material_ui]
Refactor `typography.dart` and `text_theme.dart` in preparation for M3E
(flutter/packages#13371)

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@a8549ae...13d38e0

2026-10-28 [email protected] [material_ui] Unskip long press drag test
on web (flutter/packages#13358)
2026-10-28 [email protected] [google_maps_flutter_ios, pigeon,
webview_flutter_wkwebview] Migrate remaining example apps to uiscene
(flutter/packages#13280)
2026-10-27 [email protected] manually roll flutter and fix flaky
video player test that is preventing roll from landing
(flutter/packages#13465)
2026-10-27 [email protected] [material_ui]
Unskip web tests that pass on CanvasKit and Skwasm: data_table_test,
floating_action_button_test, text_field_cursor_test
(flutter/packages#13460)
2026-10-27 [email protected] [material_ui] Decouple
disabled CheckboxListTile state in a11y_assessments
(flutter/packages#13177)
2026-10-27 [email protected] [camera_web] Skip video input
devices that cannot be started in availableCameras
(flutter/packages#13196)
2026-10-27 [email protected] [camera] Add support for
zero-shutter-lag capture (flutter/packages#12374)
2026-10-27 [email protected] [in_app_purchase_storekit} Fix more test
flakes (flutter/packages#13279)
2026-10-27 [email protected] [material_ui]
Refactor `typography.dart` and `text_theme.dart` in preparation for M3E
(flutter/packages#13371)

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.

[material_ui] Reduce code duplication in TextTheme where possible in preparation for M3E

2 participants