我有一个加载 css 文件、字体和图像文件的 html 文件。目前我的 webview 加载时没有加载任何这些辅助文件,没有显示图像,没有显示 css。我正在尝试这样:
loadHtmlFromAssets();
return WebviewScaffold(
appBar: AppBar(
title: Text("Web", style: TextStyle(color: Colors.black),),
backgroundColor: Colors.white,
iconTheme: IconThemeData(
color: Colors.black
),
),
url: 'about:blank',
withZoom: false,
withJavascript: true,
allowFileURLs: true,
withLocalUrl: true,
localUrlScope: 'assets/maphtml/',
withLocalStorage: true,
);
loadHtmlFromAssets() async {
String fileText = await rootBundle.loadString('assets/maphtml/zemelapis.html');
flutterWebViewPlugin.reloadUrl(Uri.dataFromString(fileText, mimeType: 'text/html', encoding: Encoding.getByName("utf-8")).toString());
}
html 中的资产具有 zemelapis.html 位置的假定前缀,例如
<script src="js/image-map-pro.min.js"></script>