Skip to content

Add Design Doc for Composable Text Plugins in Flutter - #35

Open
hannah-hyj wants to merge 41 commits into
flutter:mainfrom
hannah-hyj:main
Open

hannah-hyj wants to merge 41 commits into
flutter:mainfrom
hannah-hyj:main

Conversation

@hannah-hyj

@hannah-hyj hannah-hyj commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

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, and TextDelegate) in package:flutter/rendering.dart and package:flutter/widgets.dart.

This enables cross-cutting text inspection, background/foreground decoration painting, pointer gesture handling, and scroll-to-range across standard Text, RichText, and EditableText (TextField) subtrees (RenderParagraph and RenderEditable) without requiring custom text widgets or TextSpan wrappers.

Key Use Cases

  • In-page find & highlight (Ctrl+F) across lazy scrollables (ListView.builder) and text fields
  • Non-intrusive inline annotations, spellcheck/grammar squiggles, and interactive token tooltips
  • Accessibility and localization auditing overlays (e.g., text truncation, contrast, and scaling diagnostics)

Pre-launch Checklist

  • I read RFC 000.0001: Taxonomy and followed the file and path naming and metadata standards.
  • I read RFC 000.0002: Process and confirmed this proposal meets the threshold for a full RFC.
  • I read and agree to the Code of Conduct.
  • I signed the CLA.
  • I have linked an issue from flutter/flutter with the label design doc.
  • All existing and new tests are passing.
  • I have enabled "Allow edits from maintainers" on this PR so the bot can automatically assign an RFC number (or I will run dart run bin/assign_rfc_number.dart locally when instructed).

If you need help, consider asking for advice on the #hackers channel on Discord.

@hannah-hyj hannah-hyj changed the title RFC 170.0000: Composable Text Plugins in Flutter Add Design Composable Text Plugins in Flutter Oct 15, 2026
@hannah-hyj hannah-hyj changed the title Add Design Composable Text Plugins in Flutter Add Design Doc for Composable Text Plugins in Flutter Oct 15, 2026
@fanchou

This comment was marked as resolved.

@hannah-hyj

This comment was marked as resolved.

Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved

@justinmc justinmc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved

@justinmc justinmc left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
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.
@justinmc

Copy link
Copy Markdown

One feature I just realized we should have for ctrl-f: characters with diacritics in the app text should be matched by the character without the diacritic in the search text. This is how Chrome works today, for example:

Screenshot From 2026-11-12 10-25-58

@hannah-hyj
hannah-hyj requested a review from chunhtai December 4, 2026 01:39
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Outdated

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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
Comment thread rfc/170.0000-composable-text-plugins.md Resolved
@hannah-hyj
hannah-hyj requested a review from chunhtai December 5, 2026 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants