Search code examples
htmlflutterdart

String content to HTML Convert. Encode to html in flutter dart


How can I convert string to HTML encoded string in Flutter.

This is an example string

This is the sample text & special character 
also new line

I want to convert like this

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!


Solution

  • I think this is what you're looking for:

    https://api.flutter.dev/flutter/dart-convert/HtmlEscape-class.html