問題:flutter端加載放在手機本地儲存空間里的index.html檔案,有時候可以加載出來,有時候加載不出來。
(不是放在asset 里的html)
加載不出來報錯資訊:Unhandled Exception: Unable to load asset: /storage/emulated/0/Android/data/com.test.app/files/test/index.html';
當加載不出來的時候,將那個html復制多份(index1.html index2.html index3.html )然后挨個換絕對路徑,總有一個可以正常加載出來??
這到底是為啥啊,一模一樣的檔案,絕對路徑也一樣。
_loadHtmlFromAssets() async {
String filePath = '/storage/emulated/0/Android/data/com.test.app/files/test/index.html';
String fileHtmlContents = await rootBundle.loadString(filePath);
_webViewController.loadUrl(Uri.dataFromString(fileHtmlContents,
mimeType: getH5Constant.ABTEST_MIMETYPE, encoding: Encoding.getByName(getH5Constant.ABTEST_ENCODINGTYPE)).toString());
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/242076.html
標籤:Android
上一篇:列印機后臺服務批處理
