1. 08 Dec, 2023 1 commit
  2. 29 Nov, 2023 1 commit
  3. 28 Oct, 2023 1 commit
  4. 20 Sep, 2023 1 commit
    • Greg Spencer's avatar
      Remove 'must not be null' comments from painting and rendering libraries. (#134993) · fe9a2c54
      Greg Spencer authored
      ## Description
      
      This removes all of the comments that are of the form "so-and-so (must not be null|can ?not be null|must be non-null)" from the cases where those values are defines as non-nullable values.
      
      This PR removes them from the painting and rendering libraries.
      
      This was done by hand, since it really didn't lend itself to scripting, so it needs to be more than just spot-checked, I think. I was careful to leave any comment that referred to parameters that were nullable, but I may have missed some.
      
      In addition to being no longer relevant after null safety has been made the default, these comments were largely fragile, in that it was easy for them to get out of date, and not be accurate anymore anyhow.
      
      This did create a number of constructor comments which basically say "Creates a [Foo].", but I don't really know how to avoid that in a large scale change, since there's not much you can really say in a lot of cases.  I think we might consider some leniency for constructors to the "Comment must be meaningful" style guidance (which we de facto have already, since there are a bunch of these).
      
      ## Related PRs
      - https://github.com/flutter/flutter/pull/134984
      - https://github.com/flutter/flutter/pull/134991
      - https://github.com/flutter/flutter/pull/134992
      - https://github.com/flutter/flutter/pull/134994
      
      ## Tests
       - Documentation only change.
      fe9a2c54
  5. 08 Sep, 2023 1 commit
  6. 10 Aug, 2023 3 commits
  7. 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
  8. 14 Jul, 2023 1 commit
  9. 06 Jun, 2023 1 commit
  10. 31 May, 2023 1 commit
  11. 26 May, 2023 2 commits
    • 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
    • LongCatIsLooong's avatar
      Remove rounding from TextPainter (#127099) · 43de3365
      LongCatIsLooong authored
      To opt-in, run the tests with: `SKPARAGRAPH_REMOVE_ROUNDING_HACK=1 flutter test --dart-define=SKPARAGRAPH_REMOVE_ROUNDING_HACK=1 `
      
      Migration plans:
      1. Turn the flags on in CI, migrate customer tests if needed
      1. Migrate internal customers
      2. Remove the flag from skparagraph. Remove the framework flag with a manual engine roll.
      
      Also fixes https://github.com/flutter/flutter/issues/52038
      43de3365
  12. 24 May, 2023 1 commit
    • LongCatIsLooong's avatar
      Improve `TextPainter.layout` caching (#118128) · 62e78bf1
      LongCatIsLooong authored
      Improves `TextPainter.layout` caching when only the input constraints change: 
      - removes the double layout calls in `TextPainter._layoutParagraph`: now double layout is only needed when `TextAlign` is not left, and the input `maxWidth == double.infinity`.  
      - skip calls to `ui.Paragraph.layout` when it's guaranteed that there's no soft line breaks before/after the layout call.
      
      This doesn't introduce new APIs but may slightly shift text rendered on screen.
      This reduces the number of `layout` calls but since shaping results are already cached so it only skips the relatively cheap line-breaking process when possible.
      
      528 scuba failures but all of them seem reasonable.
      62e78bf1
  13. 23 May, 2023 1 commit
  14. 15 May, 2023 1 commit
  15. 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
  16. 28 Mar, 2023 1 commit
  17. 22 Mar, 2023 1 commit
  18. 13 Mar, 2023 1 commit
    • LongCatIsLooong's avatar
      Fix Caret Height On Empty Lines (#120834) · 1306d7f1
      LongCatIsLooong authored
      * improve caret caching, fix caret for empty text/line, `getLocalRectForCaret` now reports the real rect that will be painted.
      move caret x-coordinate clamping to RenderEditable since TextPainter doesn't know about clipping.
      
      * comments
      
      * review
      1306d7f1
  19. 21 Jan, 2023 1 commit
  20. 05 Jan, 2023 1 commit
  21. 28 Oct, 2022 1 commit
    • Justin McCandless's avatar
      Context Menus (#107193) · 0b451b6d
      Justin McCandless authored
      * Can show context menus anywhere in the app, not just on text.
      * Unifies all desktop/mobile context menus to go through one class (ContextMenuController).
      * All context menus are now just plain widgets that can be fully customized.
      * Existing default context menus can be customized and reused.
      0b451b6d
  22. 25 Oct, 2022 1 commit
  23. 28 Sep, 2022 1 commit
  24. 26 Sep, 2022 1 commit
  25. 16 Sep, 2022 1 commit
  26. 14 Sep, 2022 1 commit
  27. 13 Sep, 2022 1 commit
  28. 12 Sep, 2022 1 commit
  29. 06 Sep, 2022 1 commit
  30. 01 Aug, 2022 1 commit
  31. 30 Jul, 2022 1 commit
  32. 18 Jul, 2022 1 commit
  33. 01 Jul, 2022 1 commit
  34. 29 Jun, 2022 1 commit
  35. 25 May, 2022 1 commit
    • Pierre-Louis's avatar
      Use `curly_braces_in_flow_control_structures` for `foundation`, `gestures`,... · 9cc72df7
      Pierre-Louis authored
      Use `curly_braces_in_flow_control_structures` for `foundation`, `gestures`, `painting`, `physics` (#104610)
      
      * Use `curly_braces_in_flow_control_structures` for `foundation`
      
      * Use `curly_braces_in_flow_control_structures` for `gestures`
      
      * Use `curly_braces_in_flow_control_structures` for `painting`
      
      * Use `curly_braces_in_flow_control_structures` for `physics`
      
      * fix comments
      
      * remove trailing space
      
      * fix TODO style
      9cc72df7
  36. 24 May, 2022 1 commit
  37. 18 May, 2022 1 commit