文本,富文本组件-flutter_widget_from_html
Flutter-Widget-From-Html 的安装和配置
在 pubspec.yaml 文件中添加以下依赖:
dependencies: flutter_widget_from_html: ^0.10.3
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
HtmlWidget(
'<h3>Heading</h3><p>A paragraph with <strong>strong</strong>, <em>emphasized</em> and <span style="color: red">colored</span> text.</p>',
),
RichText(
text: TextSpan(
text: "Hello",
style:
TextStyle(fontWeight: FontWeight.bold, color: Colors.red),
children: [
TextSpan(
text: "<用户协议>",
style: TextStyle(color: Colors.blueAccent)),
TextSpan(text: "与", style: TextStyle(color: Colors.grey)),
TextSpan(
text: "<隐私协议>",
style: TextStyle(color: Colors.blueAccent)),
]),
),
Text(
'$_author You have pushed the button this many times:',
),
Text(
'\t\t\t\tYou have pushed the button this many timesYou have pushed the button this many times:You have pushed the button this many times:You have pushed the button this many times:You have pushed the button this many times:',
textAlign: TextAlign.right,
style: TextStyle(fontSize: 16.0),
maxLines: 2,
overflow: TextOverflow.ellipsis,
),
Text(
'$_counter,$_author',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
渲染简单的 HTML 文本
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; HtmlWidget( '<h3>Heading</h3><p>A paragraph with <strong>strong</strong>, <em>emphasized</em> and <span style="color: red">colored</span> text.</p>', )
HtmlWidget(
'同上示例',
customStylesBuilder: (element) {
if (element.classes.contains('foo')) {
return {'color': 'red'};
}
return null;
},
);
https://blog.csdn.net/diandianxiyu_geek/article/details/132157489

浙公网安备 33010602011771号