Android 14 nonlinear font scaling enabled
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 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
. To learn how to migrate to TextScaler
, check out the Deprecate textScaleFactor
in favor of TextScaler
migration guide.
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:
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
In stable release: 3.16
References
#API documentation:
Relevant issues:
Relevant PRs:
See also:
Unless stated otherwise, the documentation on this site reflects the latest stable version of Flutter. Page last updated on 2024-04-04. View source or report an issue.