在 1.20.4 版本中添加 Flutter web-view 插件时出错

use*_*135 1 flutter flutter-plugin

我想在我的应用程序中使用 flutter-web 插件。但是,当我将其添加到 YAML 文件时,我收到以下 SDK 错误。我刚刚升级到1.20.4

\n

我该如何修复这个错误?

\n

当前的 Flutter SDK 版本是 1.20.4。

\n

由于应用程序依赖于 webview_flutter >=1.0.0,需要 Flutter SDK 版本 >=1.22.0 <2.0.0,版本解析失败。\npub 失败 (1; 因为应用程序依赖于 webview_flutter >=1.0.0,需要 Flutter SDK version >=1.22.0 <2.0.0,版本解析失败。)

\n

Doctor 摘要(要查看所有详细信息,请运行 flutter doctor -v):\n[\xe2\x9c\x93] Flutter(频道稳定,1.20.4,在 Mac OS X 10.15.6 19G2021 上,区域设置 en-US)

\n

[\xe2\x9c\x93] Android 工具链 - 为 Android 设备开发(Android SDK 版本 28.0.3)\n[\xe2\x9c\x93] Xcode - 为 iOS 和 macOS 开发 (Xcode 12.0)\n[\xe2\ x9c\x93] Android Studio(版本 3.6)\n[\xe2\x9c\x93] VS Code(版本 1.49.2)\n[\xe2\x9c\x93] 连接的设备(1 个可用)

\n

\xe2\x80\xa2 未发现问题!

\n

这是我的 pubspec.yaml 文件中的信息

\n

环境:\nsdk:">=2.2.2 <3.0.0"

\n

Abh*_*ata 5

webview_flutter 包需要 minSdkVersion 19 所以你必须更改应用程序级别 gradle

android {
    defaultConfig {
        // Required by the Flutter WebView plugin.
        minSdkVersion 19
    }
  }
Run Code Online (Sandbox Code Playgroud)

使用升级你的颤振后 flutter upgrade

然后在你的 pubspec.yaml 文件中导入 webview_flutter webview_flutter: ^1.0.0因为 webview_flutter 在 flutter 1.22 稳定版本中是稳定的。