flutter widget from html
this package extends the flutter_widg,et_from_html_core package with extra functionalities by using external depedencies like cached_network_image or url_launcher. it should be good enough as a quick starting point but you can always use the core directly if you dislike the dependencies.
usage
to use this plugin, add flutter_wid,get_from_html
as a dependency in your pubspec.yaml file.
see the example app for inspiration.
example
note: htmlwi,dget.config
is optional, see dartdoc for all available configuration keys and their default values.
class helloworldscreen extends statelesswid,get {
@override
wi,dget build(buildcontext context) => scaffold(
appbar: appbar(
title: text('helloworldscreen'),
),
body: listview(
children: <widget>[
htmlwidget("""<h1>heading 1</h1>
<h2>heading 2</h2>
<h3>heading 3</h3>
<h4>heading 4</h4>
<h5>heading 5</h5>
<h6>heading 6</h6>
<p>a paragraph with <strong>strong</strong> <em>emphasized</em> text.</p>
<p>and of course, cat image: <img src="https://media.giphy.com/media/6vodjzfrjjnbg/giphy-downsized.gif" /></p>
<div style="text-align: center">source: <a href="https://gph.is/qfgpa0">https://gph.is/qfgpa0</a></div>
"""),
],
));
}
features
this package has all the features of flutter_widget_from_html_core
and some nice extras:
- renders a tag with theme accent color, launch url via
url_launcher
- renders img tag with
cachednetworkimage
and padding (config.imagepadding
) - renders lists (ol/ul) with marker and padding (
config.listbullet
,config.listpaddingleft
) - renders texts with padding (
config.textpadding
) - supports relative url (a href, img src)
Comments are closed.