English 中文(简体)
争取超文本链接。 Encode to html in flutter dart
原标题:String content to HTML Convert. Encode to html in flutter dart

我怎么能够将体力转换为光彩中编码的体。

这是一个例证。

This is the sample text & special character 
also new line

我愿改变这种态度。

This is the sample text &amp; special character <br> also new line

Not only &amp; I want all of the HTML entities available. I found HTML to string everywhere But not String to HTML anywhere! I want reversed/opposite feature what html_unescape: provide!

最佳回答
问题回答

说明如何与Dart HtmlE罪羊阶级打交道。

const HtmlEscape htmlEscape = HtmlEscape();
String unescaped =  Text & subject ; // The text you want to convert
String escaped = htmlEscape.convert(unescaped);
print(escaped); // Text &amp; subject

Using flutter_html to preview with HTML template.

import  package:html/parser.dart  as htmlparser;
import  package:html/dom.dart  as dom;
...
String htmlData = """<div>
  <h1>Demo Page</h1>
  <p>This is a fantastic product that you should buy!</p>
  <h3>Features</h3>
  <ul>
    <li>It actually works</li>
    <li>It exists</li>
    <li>It doesn t cost much!</li>
  </ul>
  <!--You can pretty much put any html in here!-->
</div>""";
dom.Document document = htmlparser.parse(htmlData);
/// sanitize or query document here
Widget html = Html(
  document: document,
);




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签