Repository navigation
[material_ui] Add fontFeatures and fontVariations to TextTheme.apply() - #12879
auto-submit[bot] merged 6 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the TextTheme.apply method in packages/material_ui/lib/src/text_theme.dart to include fontFeatures and fontVariations parameters, propagating these settings to all text styles. Corresponding tests have been added to packages/material_ui/test/text_theme_test.dart to verify the functionality. I have no further feedback to provide.
|
@nadeemmx Thanks for the PR! Please use the Pre-Review Checklist and keep it in the PR rather than deleting it.
Footnotes |
Ports flutter/flutter#192730 to flutter/packages. Adds List<FontFeature>? and List<FontVariation>? parameters to TextTheme.apply(), passing them through to each TextStyle.apply() call. This allows developers to apply font features and variations consistently across an entire text theme without modifying each TextStyle individually. Fixes flutter/flutter#192692
Adds fontFeatures and fontVariations parameters to TextTheme.apply(), matching the existing support in TextStyle.apply(). Fixes flutter/flutter#192692 Port of flutter/flutter#192730
bc4b043 to
6c2790c
Compare
|
@nadeemmx Thanks again for the contribution! If the PR is ready, feel free to put it up for review. |
There was a problem hiding this comment.
Code Review
This pull request adds fontFeatures and fontVariations parameters to TextTheme.apply() in packages/material_ui, updates the changelog, and adds corresponding unit tests. Feedback on the tests suggests replacing list reference equality checks with deep collection comparison using a loop and the expect matcher to ensure robust assertions.
| expect(themeStyles.every((TextStyle style) => style.fontFeatures == fontFeatures), true); | ||
| expect(themeStyles.every((TextStyle style) => style.fontVariations == fontVariations), true); |
There was a problem hiding this comment.
Using style.fontFeatures == fontFeatures inside every relies on reference equality for lists in Dart, which is fragile and can break if the underlying implementation of TextStyle copies or wraps the list (e.g., to ensure immutability).
Instead, use the idiomatic equals matcher in a loop, which performs deep collection comparison and provides much better failure diagnostics if the assertion fails.
for (final TextStyle style in themeStyles) {
expect(style.fontFeatures, fontFeatures);
expect(style.fontVariations, fontVariations);
}…er#193507) flutter/packages@ba0364a...3c6ce59 2026-09-29 [email protected] [cupertino_icons] Migrate to `cupertino_ui` (flutter/packages#12649) 2026-09-29 [email protected] Manual roll Flutter from 4fcd90b to c5a061b (222 revisions) (flutter/packages#13060) 2026-09-28 [email protected] Enable Built-in Kotlin in all Flutter Android Plugin Example Apps (flutter/packages#12883) 2026-09-28 [email protected] Enable Built-in Kotlin for `interactive_media_ads` (flutter/packages#12912) 2026-09-28 [email protected] [google_maps_flutter] Adopt Pigeon's Kotlin 'suspend' support (flutter/packages#12980) 2026-09-28 [email protected] [material_ui] Fix floating-point rounding errors for discrete Slider and RangeSlider (flutter/packages#13022) 2026-09-28 [email protected] [google_sign_in] PR 4/4 Convert the Pigeon host API from Objective-C to Swift (flutter/packages#12658) 2026-09-28 [email protected] [google_maps_flutter] Disable flaky web tests blocking latest flutter -> packages roll (flutter/packages#13047) 2026-09-28 [email protected] [material_ui] Add fontFeatures and fontVariations to TextTheme.apply() (flutter/packages#12879) 2026-09-28 [email protected] [in_app_purchase_storekit] Disable flaky tests blocking latest flutter -> packages roll (flutter/packages#13048) 2026-09-28 [email protected] Sync release-material_ui-1.5.0 to main (flutter/packages#13051) 2026-09-28 [email protected] Sync release-go_router-18.0.2 to main (flutter/packages#13050) 2026-09-28 [email protected] [google_fonts] Migrate to material_ui & cupertino_ui (flutter/packages#13006) 2026-09-28 [email protected] [go_router_builder] Reland material_ui migration (flutter/packages#12995) 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
Description
This PR ports flutter/flutter#192730 to flutter/packages.
Adds
List<FontFeature>?andList<FontVariation>?parameters toTextTheme.apply(), passing them through to eachTextStyle.apply()call. This allows developers to apply font features and variations consistently across an entire text theme without modifying eachTextStyleindividually.Related Issue
Fixes flutter/flutter#192692
Ports flutter/flutter#192730
Proposed Change
List<FontFeature>?andList<FontVariation>?parameters toTextTheme.apply()null, preserving backward compatibilityTextStyle.apply()calls withinTextTheme.apply()now passes these parameters throughTechnical Details
The
TextStyleclass already supportsfontFeaturesandfontVariationsin its ownapply()method. TheTextTheme.apply()method was missing the ability to pass these through. This is a purely additive change - no existing behavior is modified.Use Case: Persian Digits
Use Case: Variable Font Grade
Testing
Added 2 new tests to text_theme_test.dart:
TextTheme apply fontFeatures fontVariations- verifies all 15 styles receive the parametersTextTheme apply null fontFeatures fontVariations preserves original- verifies null defaults don't overwrite existing values (fixes incomplete test from original PR)All 18 tests pass (including existing tests).
Pre-Review Checklist
[shared_preferences]///).Note
This PR ports the original flutter/flutter PR #192730. The original PR should be closed with a reference to this new PR.
The original PR had a test that claimed to verify both
fontFeaturesandfontVariationspreservation, but only checkedfontFeatures. This has been fixed in this ported version to properly verify both properties.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