我在我的应用程序中使用 InAppWebView 并尝试显示本地 html 页面而不是标准错误消息,我已声明要在 pupspec.yaml 中使用的 html、css 和图像
# The following section is specific to Flutter.
flutter:
assets:
- assets/images/error.gif
- assets/web/error.css
- assets/web/error.html
loadHtmlFromAssets()函数负责调用onLoadError()中的本地页面
loadHtmlFromAssets() async {
String htmlFile = await rootBundle.loadString('assets/web/error.html');
setState(() {
this._webViewController.loadUrl(urlRequest: URLRequest(url: Uri.dataFromString(htmlFile,mimeType: 'text/html',encoding: Encoding.getByName("utf-8"))));
});
}
问题是html文件显示时没有css或图像,而在普通浏览器上网页显示正确。
有人能帮我吗?