一键导入
textf-usage
pkg:textf - Inline Markdown-like text formatting for Flutter (drop-in replacements for Text and TextEditingController)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
pkg:textf - Inline Markdown-like text formatting for Flutter (drop-in replacements for Text and TextEditingController)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | textf-usage |
| description | pkg:textf - Inline Markdown-like text formatting for Flutter (drop-in replacements for Text and TextEditingController) |
| user-invocable | false |
| metadata | {"version":"1.2.3"} |
Load when:
TextfOptionsstripFormatting()| Goal | Use |
|---|---|
| Display formatted text (read-only) | Textf |
| Rich-text input (formatting as user types) | TextfEditingController + TextField |
| Scoped styles or link callbacks | TextfOptions ancestor |
| Plain text from a formatted string | String.stripFormatting() |
| Format | Syntax | Alternate | Pitfall |
|---|---|---|---|
| Bold | **bold** | __bold__ | |
| Italic | *italic* | _italic_ | |
| Bold + Italic | ***both*** | ___both___ | |
| Strikethrough | ~~strike~~ | ||
| Underline | ++underline++ | ||
| Highlight | ==highlight== | ||
| Inline code | `code` | ||
| Superscript | ^super^ | ||
| Subscript | ~sub~ | ||
| Link | [label](url) | nested formatting supported | |
| Placeholder | {key} | literal text inside TextfEditingController |
Textf(
'**Bold**, *italic*, `code`, and ~~strike~~',
style: const TextStyle(fontSize: 16),
)
TextfOptions(
onLinkTap: (url, text) => launchUrl(Uri.parse(url)),
child: const Textf('[Open docs](https://dart.dev)'),
)
Textf(
'Tap {icon} to continue',
placeholders: {'icon': const WidgetSpan(child: Icon(Icons.star))},
)
final controller = TextfEditingController();
TextField(
controller: controller,
maxLines: null,
)
TextfOptions(
boldStyle: const TextStyle(fontWeight: FontWeight.w900),
onLinkTap: (url, _) => launchUrl(Uri.parse(url)),
child: Column(
children: [
const Textf('**Inherits bold style**'),
TextfOptions(
boldStyle: const TextStyle(color: Colors.red), // overrides only color; weight inherited
child: const Textf('**Red bold**'),
),
],
),
)
final plain = '**Hello** *world*'.stripFormatting(); // → 'Hello world'
Flanking rule — spaces break markers:
*italic* → italic ✓
* italic * → literal * italic * ✗
Nesting cap — max 2 levels:
**_bold italic_** ✓
**_~~third level~~_** → ~~third level~~ renders as plain text, no error ✗
Placeholders don't work in the editor:
{key} renders as the literal string {key} inside TextfEditingController. Widget injection only works in Textf.
Callback vs style inheritance — different rules:
onLinkTap, onLinkHover: nearest TextfOptions ancestor wins — no merging.boldStyle, italicStyle, …): merged property-by-property up the tree — only set the properties you want to override.Escaping markers:
Use a raw string: r'\**not bold\**'
TextfOptions APIStyle properties (all TextStyle?):
boldStyle, italicStyle, boldItalicStyle, strikethroughStyle, underlineStyle, highlightStyle, codeStyle, superscriptStyle, subscriptStyle, linkStyle, linkHoverStyle
Callbacks:
onLinkTap(String url, String text), onLinkHover(String? url, String? text)