![]() Deprecate `textScaleFactor` in favor of `textScaler`, in preparation for Android 14 [Non-linear font scaling to 200%](https://developer.android.com/about/versions/14/features#non-linear-font-scaling). The `TextScaler` class can be moved to `dart:ui` in the future, if we decide to use the Android platform API or AndroidX to get the scaling curve instead of hard coding the curve in the framework. I haven't put the Flutter version in the deprecation message so the analyzer checks are failing. Will do so after I finish the migration guide. **Why `TextScaler.textScaleFactor`** The author of a `TextScaler` subclass should provide a fallback `textScaleFactor`. By making `TextScaler` also contain the `textScaleFactor` information it also makes it easier to migrate: if a widget overrides `MediaQueryData.textScaler` in the tree, for unmigrated widgets in the subtree it would also have to override `MediaQueryData.textScaleFactor`, and that makes it difficult to remove `MediaQueryData.textScaleFactor` in the future. ## A full list of affected APIs in this PR Deprecated: The method/getter/setter/argument is annotated with a `@Deprecated()` annotation in this PR, and the caller should replace it with `textScaler` instead. Unless otherwise specified there will be a Flutter fix available to help with migration but it's still recommended to migrate case-by-case. **Replaced**: The method this `textScaleFactor` argument belongs to is rarely called directly by user code and is not overridden by any of the registered custom tests, so the argument is directly replaced by `TextScaler`. **To Be Deprecated**: The method/getter/setter/argument can't be deprecated in this PR because a registered customer test depends on it and a Flutter fix isn't available (or the test was run without applying flutter fixes first). This method/getter/setter/argument will be deprecated in a followup PR once the registered test is migrated. ### `Painting` Library | Affected API | State of `textScaleFactor` | Comment | | --- | --- | --- | | `InlineSpan.build({ double textScaleFactor = 1.0 })` argument | **Replaced** | | | `TextStyle.getParagraphStyle({ double TextScaleFactor = 1.0 })` argument | **Replaced** | | | `TextStyle.getTextStyle({ double TextScaleFactor = 1.0 })` argument| Deprecated | Can't replace: |
||
---|---|---|
.. | ||
bin | ||
data | ||
generated | ||
lib | ||
test | ||
pubspec.yaml | ||
README.md | ||
test.json |
Token Defaults Generator
Script that generates component theme data defaults based on token data.
Usage
Run this program from the root of the git repository:
dart dev/tools/gen_defaults/bin/gen_defaults.dart [-v]
This updates generated/used_tokens.csv
and the various component theme files.
Templates
There is a template file for every component that needs defaults from
the token database. These templates are implemented as subclasses of
TokenTemplate
. This base class provides some utilities and a structure
for adding a new block of generated code to the bottom of a given file.
Templates need to override the generate
method to provide the generated
code block as a string.
See lib/fab_template.dart
for an example that generates defaults for the
Floating Action Button.
Tokens
Tokens are stored in JSON files in data/
, and are sourced from
an internal Google database.
template.dart
should provide nearly all useful token resolvers
(e.g. color
, shape
, etc.). For special cases in which one shouldn't
be defined, use getToken
to get the raw token value. The script, through
the various revolvers and getToken
, validates tokens, keeps track of
which tokens are used, and generates generated/used_tokens.csv
.