Flutter富文本编辑插件advanced_rich_text的使用
Flutter富文本编辑插件advanced_rich_text的使用
简介
Flutter AdvancedRichText 是一个简单的方式来创建具有不同样式的富文本。
功能
- 可以为不同的文本设置单独的样式。
- 可以用最简单的方式创建富文本。
- 可以在其他文本中使用相同的样式,而无需重复编写代码。
选项
对于AdvancedRichText:
选项 | 描述 | 类型 | 必须 |
---|---|---|---|
initialText | 初始显示的文本 | String | 是 |
initialTextStyle | 初始显示的文本样式 | TextStyle | 否 |
secondaryTextStyle | 其他文本使用的样式 | TextStyle | 否 |
textList | 要显示的不同文本列表 | TextSpanList | 是 |
对于TextSpanList:
选项 | 描述 | 类型 | 必须 |
---|---|---|---|
text | 要显示的文本 | String | 是 |
initialTextLike | 是否使用与initialTextStyle相同的样式 | Bool | 否(默认为false) |
textStyle | 文本使用的样式 | TextStyle | 否 |
onTap | 点击后的回调函数 | Function | 否 |
使用方法
AdvanceRichText(
initialText: "Haven't liked this package, yet? ",
secondaryTextStyle: TextStyle(
color: Colors.green,
fontWeight: FontWeight.w700,
),
textList: [
TextSpanList(
text: "Please, do Like.",
),
],
),
AdvanceRichText(
initialText: "I agree that ",
secondaryTextStyle: TextStyle(
color: Colors.green,
fontWeight: FontWeight.w700,
),
textList: [
TextSpanList(
text: "AdvancedRichText ",
textStyle: TextStyle(
color: Colors.green[600],
fontWeight: FontWeight.w700,
fontSize: 24)),
TextSpanList(text: "package ", initialTextLike: true),
TextSpanList(
text: "is the easiest way to create ",
textStyle: TextStyle(
color: Colors.blue[500], fontWeight: FontWeight.w500)),
TextSpanList(
text: "different styled texts.",
textStyle: TextStyle(
color: Colors.purple[200], fontWeight: FontWeight.w700)),
TextSpanList(
text: " Agreed?",
textStyle:
TextStyle(color: Colors.red, fontWeight: FontWeight.w900)),
],
),
更多关于Flutter富文本编辑插件advanced_rich_text的使用的实战教程也可以访问 https://www.itying.com/category-92-b0.html
1 回复