Our project structure is look like below:
(b5df1cc)
common -> package1 \
\
(56e0bc0) \
common -> package2 -----> myApp
/
(101aa16) /
common -> package3 /
myApp
dependent on package1
, pacakge2
, package3
, and package1
, pacakge2
, pacakge3
dependent on common
package(git packages), but the common
package(git packages) may have different commit hash. After run flutter packages get
, it will show the error like:
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.)
Is it possible to set the version constraints or other way to ignore the "version solving failed" error for git packages? Because we can ensure that all the code from common
package(git package) is compatible with pacakge1
, package2
, package3
, if it can set the version constraints, like >=2.0.0 <3.0.0
, we can let the version never reach 3.0.0
, so myApp
can compatible with package1
, pacakge2
, package3
, etc.
Updated:
Use dependency_override can solve this problem, but the dependency_override
need to be set in the myApp
, when the common package is updated, we need to update the common package in myApp
at the same time, say if I update the common package in package1
, I need to update the common package in myApp
too, which is not what I expected.