4

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
  • 1
    I am using same way to display some form in my website in flutter, seems to be working. Maybe code review can help ? you can check source here github.com/iamSahdeep/portefeuille/blob/master/lib/UI/Screens/… Only thing seems different is that I am providing Uniquekey as well to HtmlElementView and provided height/width to iframeElement Commented Mar 14, 2021 at 13:31

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

As op stated he tried to use this package but it does not support web.
I just realized that it in fact works on web although it says it doesn't in the Scores section

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.