I am trying to embed an image within a local HTML file. and trying to load that HTML file through a flutter review. the web page texts are showing but no locally referred images are showing.
WebView
class _HomeState extends State<Home> {
WebViewController _webViewController;
@override
Widget build(BuildContext context) {
return Container(
color: Colors.orange,
child: WebView(
initialUrl: "",
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (controller){
_webViewController = controller;
_loadHtmlFromAssets();
},
),
);
}
_loadHtmlFromAssets() async {
String fileHtmlContents = await rootBundle.loadString("assets/test.html");
_webViewController.loadUrl(Uri.dataFromString(fileHtmlContents,
mimeType: 'text/html', encoding: Encoding.getByName('utf-8'))
.toString());
}
}
Html
<h1>Hellop</h1>
<img src="myimage.jpg">