Flutter webview加载本地HTML方案

@override
Widget build(BuildContext context) {
return loading?CircularProgressIndicator():WebView(
initialUrl: ‘’,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_webViewController = webViewController;
_loadHtmlFromFile();
},
);
}

_loadHtmlFromFile() async {
filePath = (await getApplicationDocumentsDirectory()).path + ‘/info.html’;
_webViewController.loadUrl(Uri.file(filePath).toString());
}

你可能感兴趣的:(软件编程)