-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Android 14 nonlinear font scaling migration guide (#9425)
## Presubmit checklist - [ ] This PR doesn’t contain automatically generated corrections (Grammarly or similar). - [ ] This PR follows the [Google Developer Documentation Style Guidelines](https://developers.google.com/style) — for example, it doesn’t use _i.e._ or _e.g._, and it avoids _I_ and _we_ (first person). - [ ] This PR uses [semantic line breaks](https://github.com/dart-lang/site-shared/blob/main/doc/writing-for-dart-and-flutter-websites.md#semantic-line-breaks) of 80 characters or fewer. --------- Co-authored-by: Anthony Sansone <atsansone@users.noreply.github.com>
- Loading branch information
1 parent
7fa68b1
commit 000cfe9
Showing
2 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
src/release/breaking-changes/android-14-nonlinear-text-scaling-migration.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
title: Android 14 nonlinear font scaling enabled after v3.14 | ||
description: > | ||
New Android 14 nonlinear font scaling feature is enabled in Flutter after v3.14. | ||
--- | ||
|
||
## Summary | ||
|
||
Android 14 introduced nonlinear font scaling up to 200%. | ||
It may change how your app looks when the user changes | ||
the accessibility text scaling in system preferences. | ||
|
||
## Background | ||
|
||
The [Android 14 nonlinear font scaling][] feature prevents excessive accessibility | ||
font scaling by scaling larger text at a lesser rate when the user increases the | ||
text scaling value in system preferences. | ||
|
||
## Migration guide | ||
|
||
As the [Android 14 feature overview][Android 14 nonlinear font scaling] suggests, | ||
test your UI with the maximum font size enabled (200%). | ||
This should verify that your app can apply the font sizes correctly | ||
and can accommodate larger font sizes without impacting usability. | ||
|
||
To adopt nonlinear font scaling in your app and custom widgets, | ||
consider migrating from `textScaleFactor` to `TextScaler`. | ||
This migration guide outlines the process: | ||
[Deprecate `textScaleFactor` in favor of `TextScaler`][], . | ||
|
||
**Temporarily Opting Out** | ||
To opt-out of nonlinear text scaling on Android 14 until you migrate your app, | ||
add a modified `MediaQuery` at the top of your app's widget tree: | ||
|
||
```dart | ||
runApp( | ||
Builder(builder: (context) { | ||
final mediaQueryData = MediaQuery.of(context); | ||
final mediaQueryDataWithLinearTextScaling = mediaQueryData | ||
.copyWith(textScaler: TextScaler.linear(mediaQueryData.textScaler.textScaleFactor)); | ||
return MediaQuery(data: mediaQueryDataWithLinearTextScaling, child: realWidgetTree); | ||
}), | ||
); | ||
``` | ||
This uses the deprecated `textScaleFactor` API. | ||
It will stop working once that API is removed from the Flutter API. | ||
|
||
## Timeline | ||
|
||
Landed in version: 3.14.0-11.0.pre<br> | ||
In stable release: not yet (Not in 3.13) | ||
|
||
## References | ||
|
||
API documentation: | ||
|
||
* [`TextScaler`][] | ||
|
||
Relevant issues: | ||
|
||
* [New font scaling system (Issue 116231)][] | ||
|
||
Relevant PRs: | ||
|
||
* [Implementing TextScaler for nonlinear text scaling][] | ||
|
||
Seealso: | ||
|
||
* [Deprecate `textScaleFactor` in favor of `TextScaler`][] | ||
|
||
[Android 14 nonlinear font scaling]: https://developer.android.com/about/versions/14/features#non-linear-font-scaling | ||
[Deprecate `textScaleFactor` in favor of `TextScaler`]: {{site.url}}/release/breaking-changes/deprecate-textscalefactor | ||
[`TextScaler`]: {{site.master-api}}/flutter/painting/TextScaler-class.html | ||
[New font scaling system (Issue 116231)]: {{site.repo.flutter}}/issues/116231 | ||
[Implementing TextScaler for nonlinear text scaling]: {{site.repo.engine}}/pull/44907 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters