-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Wire up the system text scaler from PlatformDispatcher
#159999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
862c54c to
6f263bb
Compare
|
(Triage) Confirmed with @LongCatIsLooong this is still on their radar |
This is for #159999. That PR breaks registered tests so a new matcher is added for soft transition & making it slightly easier to write tests that verify nothing is shadowing the system text scaler in the widget tree. If this approach sounds plausible & gets merged, I'm going to: 1. remake the breaking change announcement 2. update the migration guide with the new matcher, 3. migrate the registered tests and mark #159999 as ready for review. ## Pre-launch Checklist - [ ] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [ ] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [ ] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [ ] I signed the [CLA]. - [ ] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [ ] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
Flutter PR flutter/flutter#159999 (fixing a bug where MediaQuery provides an incorrect TextScaler) breaks this test; fix it with isSystemTextScaler. [chris: rewrote commit message; used package:legacy_checks]
Flutter PR flutter/flutter#159999 (fixing a bug where MediaQuery provides an incorrect TextScaler) breaks this test; fix it with isSystemTextScaler. Co-authored-by: Chris Bobbe <[email protected]>
| if (identical(this, other)) { | ||
| return true; | ||
| } | ||
| assert(minScale < maxScale); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is the only place to enforce this constraint, we should do it where these two values are set instead. a crash here won't help us much in tracing down the bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is enforced in the (private) constructor (if minScale == maxScale the public API will return a different type of TextScaler). The assert is to indicate this is a valid assumption one can make for readers. Does it make more sense to make this a code comment then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as there is not the first fail safe point, I am fine either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also fine either way, but maybe a comment is better to avoid the confusion that started this thread.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the assert.
| minScale == maxScale ? minScale.hashCode : Object.hash(scaler, minScale, maxScale); | ||
|
|
||
| @override | ||
| String toString() => '$scaler clamped [$minScale, $maxScale]'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider use Diagnosticable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't seem to reduce the amount of code I have to write, are there other benefits of using Diagnosticable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it provide a better api to fill in properties for printing the string representation. Besides that, I think devtools uses that api to get details about an object, but i am not too familiar with that part of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what it looks like now:
'│└RichText(softWrap: wrapping at box width, textScaler: SystemTextScaler (no scaling), maxLines: unlimited, text: "A", dependencies: [Directionality], renderObject: RenderParagraph#00000 relayoutBoundary=up1)\n'
So that still works. I'd keep the class hierarchy simple for now in case someone wants to implement the class instead of extending.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah makes sense
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own understanding I wonder if @kenzieschmoll has any thoughts on when to use Diagnosticable in cases like this? I've wondered about this before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renewing my LGTM 👍
| ) | ||
| double textScaleFactor = 1.0, | ||
| TextScaler textScaler = TextScaler.noScaling, | ||
| TextScaler textScaler = const _UnspecifiedTextScaler(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent use of the sentinel pattern 💂
| SystemTextScaler(:final double textScaleFactor) => this.textScaleFactor == textScaleFactor, | ||
| // When textScaleFactor is 1.0, the two TextScalers are extensionally | ||
| // equivalent. | ||
| TextScaler.noScaling => textScaleFactor == 1.0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
|
There are two Google test failures and are flakes. There are also a conflict. |
|
Waiting for my CL to land before merging this. |
|
autosubmit label was removed for flutter/flutter/159999, because - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
flutter/flutter@336a7ec...0b9f928 2025-05-14 [email protected] Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668) 2025-05-14 [email protected] Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794) 2025-05-14 [email protected] Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762) 2025-05-14 [email protected] Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754) 2025-05-14 [email protected] Add `titleAlignment` to `CheckboxListTile` and `RadioListTile` (flutter/flutter#168666) 2025-05-14 [email protected] Remove deprecated todo about caching (flutter/flutter#168534) 2025-05-13 [email protected] Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949) 2025-05-13 [email protected] Improve documentation for KeyedSubtree constructor (flutter/flutter#167198) 2025-05-13 [email protected] Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999) 2025-05-13 [email protected] Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721) 2025-05-13 [email protected] [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771) 2025-05-13 [email protected] Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702) 2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775) 2025-05-13 [email protected] Use live region in error text input decorator for Android (flutter/flutter#165531) 2025-05-13 [email protected] [tool] Fix deprecated API calls within tool (flutter/flutter#168200) 2025-05-13 [email protected] Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510) 2025-05-13 [email protected] Fixes hero not shown when remove pages without animation (flutter/flutter#168617) 2025-05-13 [email protected] [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678) 2025-05-13 [email protected] Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400) 2025-05-13 [email protected] Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736) 2025-05-13 [email protected] [web] Fix multiline input selection in Chrome. (flutter/flutter#168217) 2025-05-13 [email protected] Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
…r#9251) flutter/flutter@336a7ec...0b9f928 2025-05-14 [email protected] Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668) 2025-05-14 [email protected] Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794) 2025-05-14 [email protected] Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762) 2025-05-14 [email protected] Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754) 2025-05-14 [email protected] Add `titleAlignment` to `CheckboxListTile` and `RadioListTile` (flutter/flutter#168666) 2025-05-14 [email protected] Remove deprecated todo about caching (flutter/flutter#168534) 2025-05-13 [email protected] Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949) 2025-05-13 [email protected] Improve documentation for KeyedSubtree constructor (flutter/flutter#167198) 2025-05-13 [email protected] Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999) 2025-05-13 [email protected] Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721) 2025-05-13 [email protected] [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771) 2025-05-13 [email protected] Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702) 2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775) 2025-05-13 [email protected] Use live region in error text input decorator for Android (flutter/flutter#165531) 2025-05-13 [email protected] [tool] Fix deprecated API calls within tool (flutter/flutter#168200) 2025-05-13 [email protected] Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510) 2025-05-13 [email protected] Fixes hero not shown when remove pages without animation (flutter/flutter#168617) 2025-05-13 [email protected] [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678) 2025-05-13 [email protected] Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400) 2025-05-13 [email protected] Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736) 2025-05-13 [email protected] [web] Fix multiline input selection in Chrome. (flutter/flutter#168217) 2025-05-13 [email protected] Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
…r#9251) flutter/flutter@336a7ec...0b9f928 2025-05-14 [email protected] Fix Linux Impeller support broken by incorrect deletion of stencil buffer. (flutter/flutter#168668) 2025-05-14 [email protected] Roll Fuchsia Linux SDK from 6J81agNhuK4q255Jj... to fSvuEJgRmHxnewRJr... (flutter/flutter#168794) 2025-05-14 [email protected] Run `{Platform} flutter_packaging` builders on release candidates. (flutter/flutter#168762) 2025-05-14 [email protected] Remove `docs_deploy_beta`, fix `docs_publish`, add comments. (flutter/flutter#168754) 2025-05-14 [email protected] Add `titleAlignment` to `CheckboxListTile` and `RadioListTile` (flutter/flutter#168666) 2025-05-14 [email protected] Remove deprecated todo about caching (flutter/flutter#168534) 2025-05-13 [email protected] Replace hardcoded host and app level build.gradle paths with `AndroidProject`-level getters in `gradle_errors.dart` (flutter/flutter#167949) 2025-05-13 [email protected] Improve documentation for KeyedSubtree constructor (flutter/flutter#167198) 2025-05-13 [email protected] Wire up the system text scaler from `PlatformDispatcher` (flutter/flutter#159999) 2025-05-13 [email protected] Roll Dart SDK from 645d04a7a964 to b3520981e0f0 (3 revisions) (flutter/flutter#168721) 2025-05-13 [email protected] [a11y] Semanctis flag refactor step 3: framework part (flutter/flutter#167771) 2025-05-13 [email protected] Remove/replace the `team` label with `c: contributor-productivity`. (flutter/flutter#168702) 2025-05-13 98614782+auto-submit[bot]@users.noreply.github.com Reverts "Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (#168510)" (flutter/flutter#168775) 2025-05-13 [email protected] Use live region in error text input decorator for Android (flutter/flutter#165531) 2025-05-13 [email protected] [tool] Fix deprecated API calls within tool (flutter/flutter#168200) 2025-05-13 [email protected] Clip search artifacts in CupertinoSliverNavigationBar searchable-to-searchable transitions (flutter/flutter#168510) 2025-05-13 [email protected] Fixes hero not shown when remove pages without animation (flutter/flutter#168617) 2025-05-13 [email protected] [iOS] Do not hide selection handles when platform hides system context menu (flutter/flutter#168678) 2025-05-13 [email protected] Updated execution path to silently include --start-paused and updated tests (flutter/flutter#168400) 2025-05-13 [email protected] Roll Packages from 6a28ad9 to 2e166de (2 revisions) (flutter/flutter#168736) 2025-05-13 [email protected] [web] Fix multiline input selection in Chrome. (flutter/flutter#168217) 2025-05-13 [email protected] Call xcode_backend.dart from macos_assemble.sh (flutter/flutter#168108) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
The equality of 2
SystemTextScaleris determined by the platform'stextScaleFactorscalar, because thescalemethod is always monotonically increasing wrttextScaleFactor.On Android the scalar reflects the user configuration in system preference it seems: https://developer.android.com/reference/android/content/res/Configuration#fontScale
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.