Display locally stored html file in assets folder on browser in Flutter Web
785
You need to do two things:
- Store the HTML not in assets but in the
/web
folder where theindex.html
is. - Use
url_launcher
plugin to launch the address.
For example, imagine you have a privacy.html
file you want to open from your Flutter Web app. Copy it to the /web
folder in your project. Then use url_launcher
and call to launch()
:
launch('/privacy.html')
This will open a new browser tab with the HTML page.
Author by
user3217522
Updated on December 21, 2022Comments
-
user3217522 over 1 year
Most answers I've seen are for mobile, but is there a way to open an HTML file stored in the asset folder on the browser in the flutter web? I've tried URL launcher but couldn't find a way to get the URL of where the asset is stored. A bunch of other solutions points back to WebView on mobile but my ask is more related to the web. Any ideas?