例如:
String desc = "<bold>Hello<bold> World";
new Text(desc);
最佳答案
您可以使用 flutter_html_view包。
String html = '<bold>Hello<bold> World';
new HtmlTextView(data: html);
如果您只是想要不同的样式,可以使用 RichText
带有 TextSpans
的小部件喜欢 this .
new RichText( text: new TextSpan(text: 'Hello ', style: DefaultTextStyle.of(context).style, children:
<TextSpan>[
new TextSpan(text: 'bold', style: new TextStyle(fontWeight: FontWeight.bold)),
new TextSpan(text: ' world!'),
], ), )
https://stackoverflow.com/questions/51093559/
相关文章:
text - 如何消除 flutter 上文本上方和下方的间隙
animation - 如何为 Sprite 设置动画以移动到 flutter 的任意点?
firebase - 如何使用 flutter 删除 Firebase 存储文件?
flutter - 附加到多个 ScrollView 的 ScrollController
android - 如何使用 Flutter 构建能够拖动到全屏的底部表单小部件?
dart - 如何在 flutter 图像选择器中将图像添加到 Firestore