Load html content in flutter web?

Viewed 2306

I am trying to show a webpage in webview via html content. in android and ios flutter_html working good, but in flutter web this library not working.

I also tried this code but got no answer :

IFrameElement iframeElement = IFrameElement()
  ..src = 'url'
  ..style.border = 'none'
  ..onLoad.listen((event) {
    // perform you logic here.
  });

ui.platformViewRegistry.registerViewFactory(
  'webpage',
  (int viewId) => iframeElement,
);

return Directionality(
  textDirection: TextDirection.ltr,
  child: Center(
    child: SizedBox(
      width: double.infinity,
      height: double.infinity,
      child: HtmlElementView(viewType: 'webpage'),
    ),
  ),
);

Is there any another way to show the html content in the flutter web application?

1 Answers

I am now using flutter html to render the html content page in my app, this is the library address: https://pub.dev/packages/flutter_html. The code I am using look like this:

if (item.content != "")
              Html(
                data: item.content,
                style: {
                  "body": Style(
                    fontSize: FontSize(19.0),
                  ),
                },
                onLinkTap: (String? url, RenderContext context, Map<String, String> attributes,  dom.Element? element){
                  CommonUtils.launchUrl(url);
              }),

the item.content is my html web page source code, hope this help for you.

Related