simple_rich_text
使用简单的格式字符轻松格式化 Flutter 文本
r'/所有三种效果/(粗体、下划线和 /斜体/)。 {push:home}点击导航至主屏幕'

格式字符
| 字符 | 格式效果 |
|---|---|
| 星号 (*) | 粗体 |
| 斜杠 (/) | 斜体 |
| 下划线 (_) | 下划线 |
属性
属性对放在第一个字符标记后面的花括号中。
每对之间用分号 (;) 分隔。
每对的语法是 name:value。
| key | 含义 |
|---|---|
| color | 红、绿、蓝、黑、白、灰等 |
| pop | 弹出导航堆栈 |
| push | 将值推送到导航堆栈 |
| repl | 替换导航堆栈上的顶部路由 |
特点
- 通过在格式化文本前面加上花括号内的路由来支持到其他屏幕的文本超链接:例如,“... {calendar}转到日历屏幕”。
示例输入
'this is /italic/'
'this is *bold*'
'*_/this is all three*_/ (*bold*, _underlined_, and /italicized/)'
'you can quote characters to NOT format a word \*bold\*'
'this is _underline_'
'go to _{/myroute}home_ page'
'this is ~important~(red).'
'this is _*bold and underlined*_.'
要求
祖代必须设置 textDirection(内部 RichText 小部件需要),可以通过 MaterialApp 小部件设置,或者显式包装在 Directionality 小部件中
Directionality(
child: SimpleRichText(text: 'Peter', term: 't'),
textDirection: TextDirection.ltr)
Pull Requests
欢迎提交拉取请求!
用法
将新的依赖项行添加到您的项目/pubspec.yaml 文件中
dependencies:
...
simple_rich_text: ^1.0.28 # use latest version
别忘了 flutter pub get。
示例
请参阅示例目录。