1

我们的项目结构如下所示:

(b5df1cc)
common    -> package1 \
                       \
(56e0bc0)               \
common    -> package2 -----> myApp
                        /
(101aa16)              /
common    -> package3 /

myApp依赖于package1, pacakge2, ,package3package1,依赖于包(git包),但包(git包)可能有不同的提交哈希。运行后,它会显示如下错误:pacakge2pacakge3commoncommonflutter 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 包的“版本解决失败”错误?因为我们可以保证commonpackage(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,这不是我所期望的。

4

1 回答 1

0

可能的解决方法是使用dependency_overrides

注意:它可能会破坏 package1/2/3,因为它会强制使用它们的某些版本的通用包,而忽略它们的约束

于 2020-08-17T10:51:32.330 回答