我正在开发 Flutter 应用程序,我想安装
wakelock_plus
插件:https://pub.dev/packages/wakelock_plus
这是我运行时的输出
flutter pub add wakelock_plus
:
The current Dart SDK version is 2.19.4.
Because flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 depends on flutter_svg >=0.22.0 <1.0.0 which depends on xml ^5.0.0, flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 requires xml ^5.0.0.
And because dbus >=0.7.4 depends on xml ^6.1.0, flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 is incompatible with dbus >=0.7.4.
And because wakelock_plus <1.2.0 depends on dbus ^0.7.8 and wakelock_plus >=1.2.0 requires SDK version >=3.3.0 <4.0.0, flutter_html >=2.0.0-nullsafety.1 <3.0.0-alpha.1 is incompatible with wakelock_plus.
So, because APP_NAME depends on both flutter_html ^2.2.1 and wakelock_plus any, version solving failed.
pub finished with exit code 65
我花了几个小时试图破译这个问题,但我不知道是否有办法解决依赖冲突。
有人有建议吗?
在控制台上运行
flutter pub deps
,将所有依赖项版本递归打印为treefy 地图。然后在网站https://pub.dev上一一搜索冲突包的名称,确认是否有比你的版本更新的版本。所以你可以尝试更新 pubspec.yaml 上的版本并重新运行 flutter pub get
来检查结果。不断重复上述操作,直到控制台不再显示错误信息(目的是确保所有版本条件都满足所有冲突包)。
强制使用特定软件包版本最有用的方法如下:
# ./pubspec.yaml
dependencies:
xml: ^5.0.0
dependency_overrides:
# Maybe the latest version is 2.0.0. The package is required by the package you claimed on pubspec.yaml, but there is a critical bug on it.
wakelock_plus: 1.3.0