flutter/dev/tools/gen_defaults/lib
LongCatIsLooong b2e22d3558
Replaces textScaleFactor with TextScaler (#128522)
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: c47fd38dca/super_editor/lib/src/infrastructure/super_textfield/desktop/desktop_textfield.dart (L1903-L1905)|
| `TextPainter({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `TextPainter.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
| `TextPainter.computeWidth({ double TextScaleFactor = 1.0 })` argument | Deprecated | |
| `TextPainter.computeMaxIntrinsicWidth({ double TextScaleFactor = 1.0 })` argument | Deprecated | |

### `Rendering` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `RenderEditable({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `RenderEditable.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |
| `RenderParagraph({ double TextScaleFactor = 1.0 })` constructor argument | Deprecated | |
| `RenderParagraph.textScaleFactor` getter and setter | Deprecated | No Flutter Fix, not expressible yet |

### `Widgets` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `MediaQueryData({ double TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/test/text_scale_factor_test.dart (LL39C21-L39C35) |
| `MediaQueryData.textScaleFactor` getter | Deprecated | |
| `MediaQueryData.copyWith({ double? TextScaleFactor })` argument | Deprecated | |
| `MediaQuery.maybeTextScaleFactorOf(BuildContext context)` static method | Deprecated | No Flutter Fix, not expressible yet  |
| `MediaQuery.textScaleFactorOf(BuildContext context)` static method | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/_functions_io.dart (L68-L70), No Flutter Fix, not expressible yet |
| `RichText({ double TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/builder.dart (L829-L843) |
| `RichText.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away|
| `Text({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | 914d120da1/packages/rfw/lib/src/flutter/core_widgets.dart (L647) , No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `Text.rich({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | The default constructor has an argument that can't be deprecated right away. No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `Text.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away |
| `EditableText({ double? TextScaleFactor = 1.0 })` constructor argument | Deprecated | No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `EditableText.textScaleFactor` getter | Deprecated | |

### `Material` Library

| Affected API | State of `textScaleFactor` | Comment | 
| --- | --- | --- |
| `SelectableText({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | cd7b93532e/packages/flutter_markdown/lib/src/builder.dart (L829-L843), No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `SelectableText.rich({ double? TextScaleFactor = 1.0 })` constructor argument | **To Be Deprecated** | The default constructor has an argument that can't be deprecated right away. No Flutter Fix because of https://github.com/dart-lang/sdk/issues/52664 |
| `SelectableText.textScaleFactor` getter | **To Be Deprecated** | A constructor argument can't be deprecated right away |

A lot of material widgets (`Slider`, `RangeSlider`, `TimePicker`, and different types of buttons) also change their layout based on `textScaleFactor`. These need to be handled in a case-by-case fashion and will be migrated in follow-up PRs.
2023-07-17 17:56:07 +00:00
..
action_chip_template.dart Replaces textScaleFactor with TextScaler (#128522) 2023-07-17 17:56:07 +00:00
app_bar_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
badge_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
banner_template.dart Cleanup M3 token templates for theme lookups (#122601) 2023-03-14 17:01:13 +00:00
bottom_app_bar_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
bottom_sheet_template.dart Provide default constraints for M3 bottom sheets (#120065) 2023-04-27 09:28:11 +02:00
button_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
card_template.dart Cleanup M3 token templates for theme lookups (#122601) 2023-03-14 17:01:13 +00:00
checkbox_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
chip_template.dart Replaces textScaleFactor with TextScaler (#128522) 2023-07-17 17:56:07 +00:00
color_scheme_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
date_picker_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
dialog_template.dart Add Dialog.fullscreen and example (#112261) 2022-09-29 09:12:05 -07:00
divider_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
drawer_template.dart Fix M3 Drawer default shape in RTL (#118185) 2023-01-12 14:22:53 +00:00
expansion_tile_template.dart Reland "Update ExpansionTile to support Material 3 & add an example" (#121212) 2023-02-24 06:30:33 -08:00
fab_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
filter_chip_template.dart Replaces textScaleFactor with TextScaler (#128522) 2023-07-17 17:56:07 +00:00
icon_button_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
input_chip_template.dart Replaces textScaleFactor with TextScaler (#128522) 2023-07-17 17:56:07 +00:00
input_decorator_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
list_tile_template.dart Update ListTile text defaults to use ColorScheme (#128581) 2023-06-12 14:52:06 +00:00
menu_template.dart Update Material tokens to 0.162 (#122388) 2023-03-13 16:16:07 +00:00
navigation_bar_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
navigation_drawer_template.dart Fix NavigationDrawer selected item has wrong icon color (#129625) 2023-06-30 08:58:14 +00:00
navigation_rail_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
popup_menu_template.dart Update Material tokens to 0.162 (#122388) 2023-03-13 16:16:07 +00:00
progress_indicator_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
radio_template.dart Update Radio button to material 3 (#111774) 2022-09-20 14:09:20 -07:00
search_bar_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
search_view_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
segmented_button_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
slider_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
snackbar_template.dart Cleanup M3 token templates for theme lookups (#122601) 2023-03-14 17:01:13 +00:00
surface_tint.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
switch_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
tabs_template.dart Revert "Fix Material 3 Scrollable TabBar" (#129383) 2023-06-22 22:34:06 +00:00
template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
text_field_template.dart TextField should support disabled input text style (#119216) 2023-03-17 10:09:49 -07:00
time_picker_template.dart Reorder materialStateProperty defaults (#125905) 2023-05-11 00:03:09 +00:00
token_logger.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00
typography_template.dart Improve defaults generation with logging, stats, and token validation (#128244) 2023-06-09 11:28:18 +00:00