我们的项目结构如下所示:
(b5df1cc)
common -> package1 \
\
(56e0bc0) \
common -> package2 -----> myApp
/
(101aa16) /
common -> package3 /
myApp
依赖于package1
, pacakge2
, ,package3
和package1
,依赖于包(git包),但包(git包)可能有不同的提交哈希。运行后,它会显示如下错误:pacakge2
pacakge3
common
common
flutter packages get
Because every version of package1 from git depends on common from git {url: git@bitbucket.org:common.git, ref: b5df1cc, path: common} and every version of package2 from git depends on common from git {url: git@bitbucket.org:common.git, ref: 56e0bc0, path: common}, package1 from git is incompatible with package2 from git.
So, because myApp depends on both package2 from git and package1 from git, version solving failed.
Running "flutter pub get" in myApp...
pub get failed (1; So, because myApp depends on both package2 from git and package1 from git, version solving failed.)
是否可以设置版本约束或其他方式来忽略 git 包的“版本解决失败”错误?因为我们可以保证common
package(git package) 中的所有代码都兼容pacakge1
, package2
, package3
, 如果它可以设置版本约束, 比如>=2.0.0 <3.0.0
, 我们可以让版本永远不会达到3.0.0
, 所以myApp
可以兼容package1
, pacakge2
,package3
等。
更新:
使用dependency_override可以解决这个问题,但是dependency_override
需要在里面设置myApp
,当更新普通包的时候,我们需要同时更新里面的普通包myApp
,比如说我更新里面的普通包package1
,我需要更新也有通用包myApp
,这不是我所期望的。