flutter - 添加新的依赖项之间的冲突
问题描述
这些是我在我的依赖项pubspec.yaml
:
dependencies:
...
image_picker: ^0.8.4+2
...
一切正常,但现在我添加了这个:
dependencies:
...
image_picker: ^0.8.4+2
...
image_editor_pro: ^1.1.8
运行 pub get 我有这个错误:
因为 image_editor_pro >=1.1.0 依赖于 image_picker ^0.7.4 而 provauth 依赖于 image_picker ^0.8.4+2,所以 image_editor_pro >=1.1.0 是被禁止的。所以,由于 provauth 依赖于 image_editor_pro ^1.1.8,版本求解失败。pub get failed (1; 所以,因为 provauth 依赖于 image_editor_pro ^1.1.8,版本求解失败。)
我尝试降级我的 image_picker 版本,但出现新错误:
无法打开文件,路径 = 'C:\Users\loren\flutter.pub-cache_temp\dir60565baa\test\fixtures\invalid\n_structure_<.>.json' (操作系统错误:文件名的语法,目录or of volume is not correct (This is my bad translation of the error). , errno = 123) pub get failed (66; , errno = 123))
我能做些什么来解决和使用这两个依赖项?
解决方案
您可以尝试覆盖依赖项,以便您的项目仅使用一个版本。像这样的东西:
name: your_app
dependencies:
image_picker: ^0.8.4+2
image_editor_pro: ^1.1.8
dependency_overrides:
image_picker: '0.8.4+2' # Use only this version for all the code depended on image picker
但是您需要彻底测试依赖于被覆盖依赖项的库,以检查它是否不会给您带来新错误。
见https://dart.dev/tools/pub/dependencies#dependency-overrides
推荐阅读
- java - 启动时出现Spring燕子异常
- sql - 在 Oracle SQL 中进行 CONCAT 的另一种方法
- html - 如何修复可移动的 Div
- flutter - Flutter - 渐变色 FloatingActionButton
- android - java.lang.ArrayIndexOutOfBoundsException:长度=0;index=0 - NFC Handler.handleMessage
- json - Json响应没有迅速出现?但在邮递员的回应中
- mysql - 当有 unicode 字符用作搜索词时,MySQL LIKE 搜索不起作用
- ios - 当使用 swift5 中的 collectionview.reloaddata 新数据到达时,如何防止重绘?
- vim - 如何在 Vim 中交叉重做,即在撤消后进行一些编辑后重做更改?
- python - 使用python,如何将新项目写入CSV文件的新行