Webview加载H5页面,打开select下拉组件,弹框,ios和浏览器都正在,安卓就闪退,
- 原因分析:Android dialog的context需要传activity,而flutter传的是Application;
- 修改方法:修改webview_flutter源码,在如下位置插入代码,并把final去掉
Context appContext = context.getApplicationContext();
if (appContext instanceof FlutterApplication) {
Activity currentActivity = ((FlutterApplication) appContext).getCurrentActivity();
if (currentActivity != null) {
//获取当前context所对应的activity
context = currentActivity;
}
}
修改后的代码: