• 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
..
annotated_region_test.dart Loading commit data...
aspect_ratio_test.dart Loading commit data...
baseline_test.dart Loading commit data...
binding_pipeline_manifold_init_test.dart Loading commit data...
binding_pipeline_manifold_test.dart Loading commit data...
binding_test.dart Loading commit data...
box_constraints_test.dart Loading commit data...
box_test.dart Loading commit data...
cached_intrinsics_test.dart Loading commit data...
constraints_test.dart Loading commit data...
debug_overflow_indicator_test.dart Loading commit data...
debug_test.dart Loading commit data...
dynamic_intrinsics_test.dart Loading commit data...
editable_gesture_test.dart Loading commit data...
editable_test.dart Loading commit data...
error_test.dart Loading commit data...
first_frame_test.dart Loading commit data...
flex_overflow_test.dart Loading commit data...
flex_test.dart Loading commit data...
image_test.dart Loading commit data...
independent_layout_test.dart Loading commit data...
intrinsic_width_test.dart Loading commit data...
layer_annotations_test.dart Loading commit data...
layers_test.dart Loading commit data...
limited_box_test.dart Loading commit data...
localized_fonts_test.dart Loading commit data...
memory_allocations_test.dart Loading commit data...
mock_canvas.dart Loading commit data...
mock_canvas_test.dart Loading commit data...
mouse_tracker_cursor_test.dart Loading commit data...
mouse_tracker_test.dart Loading commit data...
mouse_tracker_test_utils.dart Loading commit data...
multi_view_binding_test.dart Loading commit data...
mutations_test.dart Loading commit data...
non_normalized_constraints_test.dart Loading commit data...
object_paint_dispose_test.dart Loading commit data...
object_test.dart Loading commit data...
offstage_test.dart Loading commit data...
overflow_test.dart Loading commit data...
paint_error_test.dart Loading commit data...
paragraph_intrinsics_test.dart Loading commit data...
paragraph_test.dart Loading commit data...
pipeline_owner_tree_test.dart Loading commit data...
platform_view_test.dart Loading commit data...
positioned_box_test.dart Loading commit data...
proxy_box_test.dart Loading commit data...
proxy_getters_and_setters_test.dart Loading commit data...
proxy_sliver_test.dart Loading commit data...
reattach_test.dart Loading commit data...
recording_canvas.dart Loading commit data...
relative_rect_test.dart Loading commit data...
relayout_boundary_test.dart Loading commit data...
rendering_tester.dart Loading commit data...
repaint_boundary_2_test.dart Loading commit data...
repaint_boundary_test.dart Loading commit data...
selection_test.dart Loading commit data...
semantics_and_children_test.dart Loading commit data...
simple_semantics_test.dart Loading commit data...
size_test.dart Loading commit data...
sliver_cache_test.dart Loading commit data...
sliver_fixed_extent_layout_test.dart Loading commit data...
sliver_persistent_header_test.dart Loading commit data...
slivers_block_test.dart Loading commit data...
slivers_helpers_test.dart Loading commit data...
slivers_layout_test.dart Loading commit data...
slivers_test.dart Loading commit data...
stack_test.dart Loading commit data...
table_border_test.dart Loading commit data...
table_test.dart Loading commit data...
transform_test.dart Loading commit data...
view_chrome_style_test.dart Loading commit data...
view_test.dart Loading commit data...
viewport_caching_test.dart Loading commit data...
viewport_test.dart Loading commit data...
wrap_test.dart Loading commit data...