custom_widgets/inline_code library
Inline code decoration.
Flutter gives an InlineSpan exactly one decoration slot — TextStyle.background, a single Paint. One Paint is a fill or a stroke, never both, and it has no corner radius and no padding. So the usual way to draw a rounded, outlined code chip is a WidgetSpan wrapping a Container — which cannot wrap across lines, breaks text selection, sits off the surrounding baseline, and does not paint on iOS when it ends up nested inside another WidgetSpan (a link label, for instance).
This library takes the approach CSS calls box-decoration-break: clone: the
code text stays a plain TextSpan, and the chip is painted underneath the
paragraph, once per line fragment. Long inline code wraps and gets one
rounded chip per line, and everything a TextSpan gives you — selection,
wrapping, baseline alignment — is preserved.
Classes
- CodeTextSpan
-
A TextSpan carrying inline
code, tagged so the paragraph can find it and paint a chip behind it. - InlineCodeRun
- A resolved inline-code run: a range of the paragraph's plain text, and the style its chip is drawn with.
- InlineCodeStyle
-
How inline
codeis drawn.
Mixins
- InlineCodeDecoration
- Paints a rounded chip behind every inline-code run, once per line fragment.
Constants
- kGptMarkdownFontPackage → const String
- The package that ships kGptMarkdownMonoFontFamily.
- kGptMarkdownMonoFontFamily → const String
- The monospace family bundled with this package, also used by code blocks.
Functions
-
baselineWidgetSpan(
Widget child) → WidgetSpan -
Wraps
childin a WidgetSpan that sits on the surrounding text baseline. -
collectInlineCodeRuns(
InlineSpan root) → List< InlineCodeRun> -
Every CodeTextSpan in
root, as plain-text ranges.