custom_widgets/inline_tap library
Tap targets inside a paragraph, resolved by text range rather than by span.
A GestureRecognizer on an InlineSpan is only effective for events that
directly hit that span's own TextSpan.text, never its
TextSpan.children: TextSpan.visitChildren skips a span whose text is
null, TextSpan.getSpanForPositionVisitor returns null for a span whose
text is null or empty, and RenderParagraph.hitTestChildren adds exactly
the one span getSpanForPosition returned. So
TextSpan(children: label, recognizer: tap) compiles, reads correctly, and
is never tapped. A WidgetSpan cannot carry a recognizer at all.
This library sidesteps both. A TappableTextSpan carries a VoidCallback, not a recognizer; collectInlineTapRuns measures it after its subtree, so a wrapper covers its whole label; and InlineTapTargets resolves a pointer to a run with RenderParagraph.getBoxesForSelection — the same public call InlineCodeDecoration already uses to paint chips. A wrapper is therefore as tappable as a leaf, and a placeholder inside a label is covered by the run around it.
Classes
- InlineTapLeafRecognizer
- The recognizer this package arms a tappable leaf with.
- InlineTapRun
- A resolved tap target: a range of the paragraph's plain text, and what to run when it is hit.
- LinkTextSpan
- A TappableTextSpan the package recognises as a link.
- TappableTextSpan
- A TextSpan that answers a tap, without carrying a GestureRecognizer.
Mixins
- InlineTapTargets
- Resolves taps on InlineTapRuns at the paragraph rather than at the span.
Functions
-
collectInlineTapRuns(
InlineSpan root) → List< InlineTapRun> -
Every TappableTextSpan in
root, as plain-text ranges.