1. 11 Aug, 2023 1 commit
  2. 09 Aug, 2023 1 commit
  3. 19 Jul, 2023 1 commit
  4. 17 Jul, 2023 1 commit
    • 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
  5. 27 Jun, 2023 1 commit
    • hangyu's avatar
      Fix chinese text is not selected by long press (#129320) · 9459f1c5
      hangyu authored
      issue:#126652
      
       in Chinese text, word length is 1 and (position.offset == word.end) happens a lot.
      
      Update if (position.offset >= word.end) to if (position.offset > word.end) to resolve the issue that Chinese characters are not selected.
      9459f1c5
  6. 21 Jun, 2023 1 commit
    • Renzo Olivares's avatar
      Selection area right click behavior should match native (#128224) · b36ef583
      Renzo Olivares authored
      This change updates `SelectableRegion`s right-click gesture to match native platform behavior.
      
      Before: Right-click gesture selects word at position and opens context menu (All Platforms)
      After: 
      - Linux, toggles context menu on/off, and collapses selection when click was not on an active selection (uncollapsed).
      - Windows, Android, Fuchsia, shows context menu at right-clicked position (unless the click is at an active selection).
      - macOS, toggles the context menu if right click was at the same position as the previous / or selects word at position and opens context menu.
      - iOS, selects word at position and opens context menu.
      
      This change also prevents the `copy` menu button from being shown when there is a collapsed selection (nothing to copy).
      
      Fixes #117561
      b36ef583
  7. 09 Jun, 2023 1 commit
  8. 06 Jun, 2023 1 commit
    • Renzo Olivares's avatar
      handleSelectWord in MultiSelectableSelectionContainerDelegate should handle... · 0e1056f8
      Renzo Olivares authored
      handleSelectWord in MultiSelectableSelectionContainerDelegate should handle rects inside of rects (#127478)
      
      Fixes #127076
      
      Sometimes a `Selectable`s rect may contain another `Selectable`s rect within it. In the case of `handleSelectWord` when choosing which `Selectable` to dispatch the `SelectionEvent` to, the event would be dispatched to the wrong `Selectable` causing an assertion error to be thrown. 
      
      <img width="577" alt="Screenshot 2023-05-24 at 2 46 13 AM" src="https://github.com/flutter/flutter/assets/948037/bb246966-acad-4d81-bd87-758c3ea6ea39">
      
      In the picture above the red outline shows the rect of a two-line piece of text. And the blue rect shows the rect of a piece of text that is on the second line of the two-line piece of text, but has been separated into its own rect for some case, for example when `TextSpan`s are separated by a `WidgetSpan`.
      
      We should check if the text layout of the selectable that has been dispatched the SelectionEvent contains the word, if not then return `SelectionResult.next`, and continue to look through the list of selectables.
      0e1056f8
  9. 26 May, 2023 1 commit
    • LongCatIsLooong's avatar
      Move shared inline widget logic to `RenderInlineWidgetContainerDefaults` (#127308) · b5df180a
      LongCatIsLooong authored
      - Added `InlineWidgetContainerDefaults` for deduping inline widget code
      - Added a helper function `WidgetSpan.extractFromInlineSpan` for extracting `WidgetSpan`s and automatically applying text scaling (at widget level)
      - Removed `TextPainter.inlinePlaceholderScales`. I'm going to deprecate the `scale` argument in `TextPainter.addPlaceholder` next, as scaling is now done at the widget level.
      - Added runtime check and comments to make sure nobody is extending `PlaceholderSpan` directly (unfortunately we can't remove `PlaceholderSpan`  without moving RenderEditable and RenderParagraph to the widgets library).
      b5df180a
  10. 15 May, 2023 1 commit
  11. 03 May, 2023 1 commit
    • LongCatIsLooong's avatar
      Add `InlineSpan.visitDirectChildren` (#125656) · f704c689
      LongCatIsLooong authored
      I'd like to find out the `fontSize` of a `PlaceholderSpan`, and currently there doesn't seem to be a way to do `TextStyle` cascading in the framework:
      
       `InlineSpan.visitChildren` traverses the entire `InlineSpan` tree using a preorder traversal, and nodes that don't have "content" will be skipped (https://master-api.flutter.dev/flutter/painting/InlineSpan/visitChildren.html): 
      
      > Walks this [InlineSpan](https://master-api.flutter.dev/flutter/painting/InlineSpan-class.html) and any descendants in pre-order and calls visitor for each span that has content.
      
      which makes it impossible to do `TextStyle` cascading in the framework: 
      - `InlineSpan`s with a non-null `TextStyle` but has no content will be skipped
      - `visitChildren` doesn't directly expose the hierarchy, it only gives information about the flattened tree.
      
      This doesn't look like a breaking change, most internal customers are extending `WidgetSpan` which has a concrete implementation of the new method.
      
      Alternatively I could create a fake `ui.ParagraphBuilder` and record the `ui.TextStyle` at the top of the stack when `addPlaceholder` is called. But `ui.TextStyle` properties are not exposed to the framework.
      f704c689
  12. 22 Mar, 2023 1 commit
  13. 01 Mar, 2023 1 commit
    • chunhtai's avatar
      Issues/111931 reland (#121576) · 978d9b55
      chunhtai authored
      * Revert "Revert "Fix text.rich to merge widget span (#113461)" (#121562)"
      
      This reverts commit c8d80163.
      
      * Fixes tag to not pollute cached semantics configuration in rendering object
      978d9b55
  14. 27 Feb, 2023 1 commit
  15. 23 Feb, 2023 1 commit
  16. 21 Jan, 2023 1 commit
  17. 05 Jan, 2023 1 commit
  18. 16 Dec, 2022 2 commits
  19. 04 Nov, 2022 1 commit
  20. 06 Sep, 2022 1 commit
  21. 11 Aug, 2022 1 commit
  22. 30 Jul, 2022 1 commit
  23. 18 Jul, 2022 1 commit
  24. 01 Jul, 2022 1 commit
  25. 29 Jun, 2022 1 commit
  26. 17 Jun, 2022 1 commit
  27. 25 May, 2022 1 commit
  28. 24 May, 2022 1 commit
  29. 18 Apr, 2022 1 commit
  30. 14 Apr, 2022 1 commit
  31. 24 Mar, 2022 1 commit
  32. 01 Mar, 2022 1 commit
  33. 22 Feb, 2022 1 commit
  34. 01 Dec, 2021 1 commit
  35. 11 Oct, 2021 1 commit
  36. 08 Oct, 2021 3 commits
  37. 27 Sep, 2021 1 commit