Webview添加监听
//记载监听用于在dialog上回调
late Function(int progress)? loadingListener;
WebView(
initialUrl: ServiceUrl.homeWeb,
//javascript是否启用默认是(JavascriptMode.disabled禁用)
javascriptMode: JavascriptMode.unrestricted,
//开始加载
onPageStarted: (url) {
_showLoadingDialog(context);
},
onProgress: (int progress) {
loadingListener?.call(progress);
print('记载=$progress');
},
//加载结束
onPageFinished: (url) {
if (loadingDialogContext != null) {
Navigator.pop(loadingDialogContext!);
}
},
//加载错误
onWebResourceError: (WebResourceError error) {
if (loadingDialogContext <