Flutter webview_flutter下拉select组件报错

Webview加载H5页面,打开select下拉组件,弹框,ios和浏览器都正在,安卓就闪退,

  • 原因分析:Android dialog的context需要传activity,而flutter传的是Application;
  • 修改方法:修改webview_flutter源码,在如下位置插入代码,并把final去掉
    Flutter webview_flutter下拉select组件报错_第1张图片
Context appContext = context.getApplicationContext();
    if (appContext instanceof FlutterApplication) {
      Activity currentActivity = ((FlutterApplication) appContext).getCurrentActivity();

      if (currentActivity != null) {
        //获取当前context所对应的activity
        context = currentActivity;
      }
    }

修改后的代码:
Flutter webview_flutter下拉select组件报错_第2张图片

你可能感兴趣的:(flutter)