【发布时间】:2020-03-26 13:47:53
【问题描述】:
我需要显示来自服务器的颤振数据,其中包含一些 HTML 标记。
我使用了flutter_html。 当我在源代码中编写 HTML 标签时它正在工作。 但是当我尝试从 API 显示包含 html 标签的文本时,它不起作用。所有标签都显示在应用程序上。
Widget textSection = Container(
padding: const EdgeInsets.only(top:10,right:20,bottom:10,left:28),
child: Html(
data: """
${event.details} + <p> I am</p>
""",
padding: EdgeInsets.all(8.0),
linkStyle: const TextStyle(
color: Colors.redAccent,
decorationColor: Colors.redAccent,
decoration: TextDecoration.underline,
),
onLinkTap: (url) {
print("Opening $url...");
},
onImageTap: (src) {
print(src);
},
customRender: (node, children) {
if (node is dom.Element) {
switch (node.localName) {
case "custom_tag":
return Column(children: children);
}
}
return null;
},
customTextAlign: (dom.Node node) {
if (node is dom.Element) {
switch (node.localName) {
case "p":
return TextAlign.justify;
}
}
return null;
},
customTextStyle: (dom.Node node, TextStyle baseStyle) {
if (node is dom.Element) {
switch (node.localName) {
case "p":
return baseStyle.merge(TextStyle(height: 2, fontSize: 20));
}
}
return baseStyle;
},
),
);
【问题讨论】: