skip to Main Content

I am using url_launcher package and trying to open a link like this:

try {
    final Uri launchUri = Uri.dataFromString(
        '<html><body>hello world</body></html>',
        mimeType: 'text/html');
    await launchUrl(launchUri);
  } catch (e) {
    print(e);
  }

Only a blank screen with empty head and body tags open.

There is no error in the console.

How do I open an html file hard coded on flutter on a new window on flutter web?

should i create a blob?

2

Answers


  1. One possibility is, save the generated html to the local file system. Then open that local file (with a file url) in the new window.

    Login or Signup to reply.
  2. Try This Package : flutter_html

    Example :

    Widget html = Html(
      data: """<div>
            <h1>Demo Page</h1>
            <p>This is a fantastic product that you should buy!</p>
            <h3>Features</h3>
            <ul>
              <li>It actually works</li>
              <li>It exists</li>
              <li>It doesn't cost much!</li>
            </ul>
            <!--You can pretty much put any html in here!-->
          </div>""",
    );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search