Hi everyone,
I have an html file with structured text: colors, size of text, bold, italic etc. and I need to render it in Flutter. I’ve read about the flutter_html package, is it reliable in mobile production environment? On pub.dev it is pretty popular, but the last update is from 2 years ago and it gets a pub score of 80/160.
It looks like flutter_html is for parsing HTML, not rendering it. It uses the webview_flutter package for rendering.
I’d just use webview_flutter directly.
Thank you very much! I’ll try to use webview_flutter.
Actually, I’m deciding on the best approach for my use case: I have structured text, and I’m exploring the best way to store it. Besides HTML, I considered using a simple JSON file, where the data is a list of objects containing a type and content. Based on the type, I’d implement a different style in a Text Widget. I’m leaning toward the JSON solution but plan to test both approaches before making a final decision. What do you think?
Another format you might consider is Markdown. There are a couple packages that help deal with that. I think there are also a couple packages that will take simple HTML and convert to Flutter widgets.
I ended up using straight HTML with webview_flutter because I wanted more formatting flexibility than the other packages offered. It’s kind of a pain writing the HTML to disk, along with the accompanying fonts and images, but it works out well in the end.
I decided against using Markdown because the Flutter Markdown parser doesn’t support inline HTML, meaning I wouldn’t be able to set colors, for example.
I’d have to manually parse certain tags in the Markdown, so at that point, I’d prefer the JSON solution.