• 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
..
_platform_selectable_region_context_menu_io.dart Loading commit data...
_platform_selectable_region_context_menu_web.dart Loading commit data...
actions.dart Loading commit data...
adapter.dart Loading commit data...
animated_cross_fade.dart Loading commit data...
animated_scroll_view.dart Loading commit data...
animated_size.dart Loading commit data...
animated_switcher.dart Loading commit data...
annotated_region.dart Loading commit data...
app.dart Loading commit data...
app_lifecycle_listener.dart Loading commit data...
async.dart Loading commit data...
autocomplete.dart Loading commit data...
autofill.dart Loading commit data...
automatic_keep_alive.dart Loading commit data...
banner.dart Loading commit data...
basic.dart Loading commit data...
binding.dart Loading commit data...
bottom_navigation_bar_item.dart Loading commit data...
color_filter.dart Loading commit data...
constants.dart Loading commit data...
container.dart Loading commit data...
context_menu_button_item.dart Loading commit data...
context_menu_controller.dart Loading commit data...
debug.dart Loading commit data...
decorated_sliver.dart Loading commit data...
default_selection_style.dart Loading commit data...
default_text_editing_shortcuts.dart Loading commit data...
desktop_text_selection_toolbar_layout_delegate.dart Loading commit data...
dismissible.dart Loading commit data...
display_feature_sub_screen.dart Loading commit data...
disposable_build_context.dart Loading commit data...
drag_target.dart Loading commit data...
draggable_scrollable_sheet.dart Loading commit data...
dual_transition_builder.dart Loading commit data...
editable_text.dart Loading commit data...
fade_in_image.dart Loading commit data...
focus_manager.dart Loading commit data...
focus_scope.dart Loading commit data...
focus_traversal.dart Loading commit data...
form.dart Loading commit data...
framework.dart Loading commit data...
gesture_detector.dart Loading commit data...
grid_paper.dart Loading commit data...
heroes.dart Loading commit data...
icon.dart Loading commit data...
icon_data.dart Loading commit data...
icon_theme.dart Loading commit data...
icon_theme_data.dart Loading commit data...
image.dart Loading commit data...
image_filter.dart Loading commit data...
image_icon.dart Loading commit data...
implicit_animations.dart Loading commit data...
inherited_model.dart Loading commit data...
inherited_notifier.dart Loading commit data...
inherited_theme.dart Loading commit data...
interactive_viewer.dart Loading commit data...
keyboard_listener.dart Loading commit data...
layout_builder.dart Loading commit data...
list_wheel_scroll_view.dart Loading commit data...
localizations.dart Loading commit data...
lookup_boundary.dart Loading commit data...
magnifier.dart Loading commit data...
media_query.dart Loading commit data...
modal_barrier.dart Loading commit data...
navigation_toolbar.dart Loading commit data...
navigator.dart Loading commit data...
nested_scroll_view.dart Loading commit data...
notification_listener.dart Loading commit data...
orientation_builder.dart Loading commit data...
overflow_bar.dart Loading commit data...
overlay.dart Loading commit data...
overscroll_indicator.dart Loading commit data...
page_storage.dart Loading commit data...
page_view.dart Loading commit data...
pages.dart Loading commit data...
performance_overlay.dart Loading commit data...
placeholder.dart Loading commit data...
platform_menu_bar.dart Loading commit data...
platform_selectable_region_context_menu.dart Loading commit data...
platform_view.dart Loading commit data...
preferred_size.dart Loading commit data...
primary_scroll_controller.dart Loading commit data...
raw_keyboard_listener.dart Loading commit data...
reorderable_list.dart Loading commit data...
restoration.dart Loading commit data...
restoration_properties.dart Loading commit data...
router.dart Loading commit data...
routes.dart Loading commit data...
safe_area.dart Loading commit data...
scroll_activity.dart Loading commit data...
scroll_aware_image_provider.dart Loading commit data...
scroll_configuration.dart Loading commit data...
scroll_context.dart Loading commit data...
scroll_controller.dart Loading commit data...
scroll_delegate.dart Loading commit data...
scroll_metrics.dart Loading commit data...
scroll_notification.dart Loading commit data...
scroll_notification_observer.dart Loading commit data...
scroll_physics.dart Loading commit data...
scroll_position.dart Loading commit data...
scroll_position_with_single_context.dart Loading commit data...
scroll_simulation.dart Loading commit data...
scroll_view.dart Loading commit data...
scrollable.dart Loading commit data...
scrollable_helpers.dart Loading commit data...
scrollbar.dart Loading commit data...
selectable_region.dart Loading commit data...
selection_container.dart Loading commit data...
semantics_debugger.dart Loading commit data...
service_extensions.dart Loading commit data...
shared_app_data.dart Loading commit data...
shortcuts.dart Loading commit data...
single_child_scroll_view.dart Loading commit data...
size_changed_layout_notifier.dart Loading commit data...
sliver.dart Loading commit data...
sliver_fill.dart Loading commit data...
sliver_layout_builder.dart Loading commit data...
sliver_persistent_header.dart Loading commit data...
sliver_prototype_extent_list.dart Loading commit data...
slotted_render_object_widget.dart Loading commit data...
snapshot_widget.dart Loading commit data...
spacer.dart Loading commit data...
spell_check.dart Loading commit data...
status_transitions.dart Loading commit data...
table.dart Loading commit data...
tap_and_drag_gestures.dart Loading commit data...
tap_region.dart Loading commit data...
text.dart Loading commit data...
text_editing_intents.dart Loading commit data...
text_selection.dart Loading commit data...
text_selection_toolbar_anchors.dart Loading commit data...
text_selection_toolbar_layout_delegate.dart Loading commit data...
texture.dart Loading commit data...
ticker_provider.dart Loading commit data...
title.dart Loading commit data...
transitions.dart Loading commit data...
tween_animation_builder.dart Loading commit data...
two_dimensional_scroll_view.dart Loading commit data...
two_dimensional_viewport.dart Loading commit data...
undo_history.dart Loading commit data...
unique_widget.dart Loading commit data...
value_listenable_builder.dart Loading commit data...
view.dart Loading commit data...
viewport.dart Loading commit data...
visibility.dart Loading commit data...
widget_inspector.dart Loading commit data...
widget_span.dart Loading commit data...
will_pop_scope.dart Loading commit data...
window.dart Loading commit data...