• LongCatIsLooong's avatar
    Replaces `textScaleFactor` with `TextScaler` (#128522) · b2e22d35
    LongCatIsLooong authored
    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: https://github.com/superlistapp/super_editor/blob/c47fd38dca4b7f43611690913b551a1773c563d7/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** | https://github.com/flutter/packages/blob/cd7b93532e5cb605a42735e20f1de70fc00adae7/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** | https://github.com/flutter/packages/blob/cd7b93532e5cb605a42735e20f1de70fc00adae7/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** | https://github.com/flutter/packages/blob/cd7b93532e5cb605a42735e20f1de70fc00adae7/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** | https://github.com/flutter/packages/blob/914d120da12fba458c020210727831c31bd71041/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** | https://github.com/flutter/packages/blob/cd7b93532e5cb605a42735e20f1de70fc00adae7/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.
    b2e22d35
Name
Last commit
Last update
..
animated_icons Loading commit data...
shaders Loading commit data...
about.dart Loading commit data...
action_buttons.dart Loading commit data...
action_chip.dart Loading commit data...
action_icons_theme.dart Loading commit data...
adaptive_text_selection_toolbar.dart Loading commit data...
animated_icons.dart Loading commit data...
app.dart Loading commit data...
app_bar.dart Loading commit data...
app_bar_theme.dart Loading commit data...
arc.dart Loading commit data...
autocomplete.dart Loading commit data...
back_button.dart Loading commit data...
badge.dart Loading commit data...
badge_theme.dart Loading commit data...
banner.dart Loading commit data...
banner_theme.dart Loading commit data...
bottom_app_bar.dart Loading commit data...
bottom_app_bar_theme.dart Loading commit data...
bottom_navigation_bar.dart Loading commit data...
bottom_navigation_bar_theme.dart Loading commit data...
bottom_sheet.dart Loading commit data...
bottom_sheet_theme.dart Loading commit data...
button.dart Loading commit data...
button_bar.dart Loading commit data...
button_bar_theme.dart Loading commit data...
button_style.dart Loading commit data...
button_style_button.dart Loading commit data...
button_theme.dart Loading commit data...
calendar_date_picker.dart Loading commit data...
card.dart Loading commit data...
card_theme.dart Loading commit data...
checkbox.dart Loading commit data...
checkbox_list_tile.dart Loading commit data...
checkbox_theme.dart Loading commit data...
chip.dart Loading commit data...
chip_theme.dart Loading commit data...
choice_chip.dart Loading commit data...
circle_avatar.dart Loading commit data...
color_scheme.dart Loading commit data...
colors.dart Loading commit data...
constants.dart Loading commit data...
curves.dart Loading commit data...
data_table.dart Loading commit data...
data_table_source.dart Loading commit data...
data_table_theme.dart Loading commit data...
date.dart Loading commit data...
date_picker.dart Loading commit data...
date_picker_theme.dart Loading commit data...
debug.dart Loading commit data...
desktop_text_selection.dart Loading commit data...
desktop_text_selection_toolbar.dart Loading commit data...
desktop_text_selection_toolbar_button.dart Loading commit data...
dialog.dart Loading commit data...
dialog_theme.dart Loading commit data...
divider.dart Loading commit data...
divider_theme.dart Loading commit data...
drawer.dart Loading commit data...
drawer_header.dart Loading commit data...
drawer_theme.dart Loading commit data...
dropdown.dart Loading commit data...
dropdown_menu.dart Loading commit data...
dropdown_menu_theme.dart Loading commit data...
elevated_button.dart Loading commit data...
elevated_button_theme.dart Loading commit data...
elevation_overlay.dart Loading commit data...
expand_icon.dart Loading commit data...
expansion_panel.dart Loading commit data...
expansion_tile.dart Loading commit data...
expansion_tile_theme.dart Loading commit data...
feedback.dart Loading commit data...
filled_button.dart Loading commit data...
filled_button_theme.dart Loading commit data...
filter_chip.dart Loading commit data...
flexible_space_bar.dart Loading commit data...
floating_action_button.dart Loading commit data...
floating_action_button_location.dart Loading commit data...
floating_action_button_theme.dart Loading commit data...
flutter_logo.dart Loading commit data...
grid_tile.dart Loading commit data...
grid_tile_bar.dart Loading commit data...
icon_button.dart Loading commit data...
icon_button_theme.dart Loading commit data...
icons.dart Loading commit data...
ink_decoration.dart Loading commit data...
ink_highlight.dart Loading commit data...
ink_ripple.dart Loading commit data...
ink_sparkle.dart Loading commit data...
ink_splash.dart Loading commit data...
ink_well.dart Loading commit data...
input_border.dart Loading commit data...
input_chip.dart Loading commit data...
input_date_picker_form_field.dart Loading commit data...
input_decorator.dart Loading commit data...
list_tile.dart Loading commit data...
list_tile_theme.dart Loading commit data...
magnifier.dart Loading commit data...
material.dart Loading commit data...
material_button.dart Loading commit data...
material_localizations.dart Loading commit data...
material_state.dart Loading commit data...
material_state_mixin.dart Loading commit data...
menu_anchor.dart Loading commit data...
menu_bar_theme.dart Loading commit data...
menu_button_theme.dart Loading commit data...
menu_style.dart Loading commit data...
menu_theme.dart Loading commit data...
mergeable_material.dart Loading commit data...
navigation_bar.dart Loading commit data...
navigation_bar_theme.dart Loading commit data...
navigation_drawer.dart Loading commit data...
navigation_drawer_theme.dart Loading commit data...
navigation_rail.dart Loading commit data...
navigation_rail_theme.dart Loading commit data...
no_splash.dart Loading commit data...
outlined_button.dart Loading commit data...
outlined_button_theme.dart Loading commit data...
page.dart Loading commit data...
page_transitions_theme.dart Loading commit data...
paginated_data_table.dart Loading commit data...
popup_menu.dart Loading commit data...
popup_menu_theme.dart Loading commit data...
progress_indicator.dart Loading commit data...
progress_indicator_theme.dart Loading commit data...
radio.dart Loading commit data...
radio_list_tile.dart Loading commit data...
radio_theme.dart Loading commit data...
range_slider.dart Loading commit data...
refresh_indicator.dart Loading commit data...
reorderable_list.dart Loading commit data...
scaffold.dart Loading commit data...
scrollbar.dart Loading commit data...
scrollbar_theme.dart Loading commit data...
search.dart Loading commit data...
search_anchor.dart Loading commit data...
search_bar_theme.dart Loading commit data...
search_view_theme.dart Loading commit data...
segmented_button.dart Loading commit data...
segmented_button_theme.dart Loading commit data...
selectable_text.dart Loading commit data...
selection_area.dart Loading commit data...
shadows.dart Loading commit data...
slider.dart Loading commit data...
slider_theme.dart Loading commit data...
snack_bar.dart Loading commit data...
snack_bar_theme.dart Loading commit data...
spell_check_suggestions_toolbar.dart Loading commit data...
spell_check_suggestions_toolbar_layout_delegate.dart Loading commit data...
stepper.dart Loading commit data...
switch.dart Loading commit data...
switch_list_tile.dart Loading commit data...
switch_theme.dart Loading commit data...
tab_bar_theme.dart Loading commit data...
tab_controller.dart Loading commit data...
tab_indicator.dart Loading commit data...
tabs.dart Loading commit data...
text_button.dart Loading commit data...
text_button_theme.dart Loading commit data...
text_field.dart Loading commit data...
text_form_field.dart Loading commit data...
text_selection.dart Loading commit data...
text_selection_theme.dart Loading commit data...
text_selection_toolbar.dart Loading commit data...
text_selection_toolbar_text_button.dart Loading commit data...
text_theme.dart Loading commit data...
theme.dart Loading commit data...
theme_data.dart Loading commit data...
time.dart Loading commit data...
time_picker.dart Loading commit data...
time_picker_theme.dart Loading commit data...
toggle_buttons.dart Loading commit data...
toggle_buttons_theme.dart Loading commit data...
toggleable.dart Loading commit data...
tooltip.dart Loading commit data...
tooltip_theme.dart Loading commit data...
tooltip_visibility.dart Loading commit data...
typography.dart Loading commit data...
user_accounts_drawer_header.dart Loading commit data...