Repository navigation
Add Design Doc for Composable Text Plugins in Flutter - #35
hannah-hyj wants to merge 41 commits into
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
justinmc
left a comment
There was a problem hiding this comment.
Quick drive by review until I can take a deeper look:
The demo is awesome. Can you share the source code? I think the repo (https://github.com/hannah-hyj/flutter_text_plugin_demo) contains only the compiled assets.
One thing we should be wary of in this design is complexity that increases with the amount of text on the page. Flutter is currently already pretty bad at handling large amounts of text, but we should avoid making that worse if we can.
justinmc
left a comment
There was a problem hiding this comment.
There are probably lots of little details about whether we want to expose certain properties on some of the core classes, etc. but overall I think this looks really good for such an ambitious project. The demo is really great proof of this idea.
For the record I was reviewing the code and example code here: flutter/flutter@master...hannah-hyj:flutter:text-plugin-testing
Stage 1 (painter only) is the proposal. Stages 2 and 3 are described as future stages with what each experiment showed. Removes the pointer event API, corrects places where the text disagreed with the prototype, drops the mermaid diagrams, and adds sections on plugin ownership, performance, the limits of stage 1, open questions and live demos.
|
|
||
| Whether the API should make that difference visible, with separate fields or a rule in the merge, is an open question ([Section 12](#12-open-questions)). | ||
|
|
||
| **The name.** `TextSpanDecoration` is the name in the PRs. It says where the data ends up, in a `TextSpan`. Two things speak against it: it is close to `TextDecoration`, which is the underline of a `TextStyle`, and "decoration" fits a style better than it fits a recognizer or a replacement. Two other names were considered, in case the review prefers one: |
There was a problem hiding this comment.
non blocking, decoration has special meaning in terms of input decoration and boxdecoration, which is to draw outline around a item.
some other idea will be SpanOverride, SpanAddition. but I am not feel to strongly about this
There was a problem hiding this comment.
I keep TextSpanDecoration in the PRs for the moment and will rename once in the review of PR 1, when we have settled on one. @LongCatIsLooong do you have a preferred name for this?
…n a surrogate pair asserts

demos:
Stage 1 (painter only): https://text-plugin-mvp-demo.web.app/
Stage 2 (annotations): https://text-plugin-annotations-demo.web.app/
Stage 3 (widgets): https://text-plugin-widget-demo.web.app/
Prototype branches link:
Stage 1 (painter only): https://github.com/hannah-hyj/flutter/tree/text-plugin-mvp
Stage 2 (annotations): https://github.com/hannah-hyj/flutter/tree/text-plugin-annotations
Stage 3 (widgets): https://github.com/hannah-hyj/flutter/tree/text-plugin-with-widget
text-plugin-selection: https://github.com/hannah-hyj/flutter/tree/text-plugin-selection
If you want to access demo app code , it's in {branch}/examples/text_plugins
issue: flutter/flutter#65504
#25 was closed in favor of this one
Summary
Proposes a composable text plugin architecture (
TextPluginScope,TextPlugin, andTextDelegate) inpackage:flutter/rendering.dartandpackage:flutter/widgets.dart.This enables cross-cutting text inspection, background/foreground decoration painting, pointer gesture handling, and scroll-to-range across standard
Text,RichText, andEditableText(TextField) subtrees (RenderParagraphandRenderEditable) without requiring custom text widgets orTextSpanwrappers.Key Use Cases
Ctrl+F) across lazy scrollables (ListView.builder) and text fieldsPre-launch Checklist
design doc.dart run bin/assign_rfc_number.dartlocally when instructed).If you need help, consider asking for advice on the #hackers channel on Discord.