Home > Net >  Flutter pubspec dependency conflict
Flutter pubspec dependency conflict

Time:01-05

I've a wired problem with resolving dependencies. In my application pubspec I've following lines:

dependencies:
  yet_another_layout_builder: ^0.1.0

dev_dependencies:
  hive_generator: ^1.1.1

both packages uses analyzer package and flutter pub get reports me an error:

Because no versions of hive_generator match >1.1.1 <2.0.0 and hive_generator 1.1.1 depends on analyzer >=1.0.0 <3.0.0, hive_generator ^1.1.1 requires analyzer >=1.0.0 <3.0.0.

And because every version of yet_another_layout_builder depends on analyzer ^3.0.0, hive_generator ^1.1.1 is incompatible with yet_another_layout_builder.

So, because testApp depends on both yet_another_layout_builder ^0.1.0 and hive_generator ^1.1.1, version solving failed.

pub get failed (1; So, because testApp depends on both yet_another_layout_builder ^0.1.0 and hive_generator ^1.1.1, version solving failed.)

However when I look into github sources for those packages, it looks for me that this error shouldn't happen. For hive_generator pubspec have following restrictions:

dependencies:
  analyzer: ">=1.0.0 <4.0.0"

and for YetAnotherLayoutBuilder pubspec have:

dependencies:
  analyzer: ^3.0.0

So if I understands this notation correctly:

  • YetAnotherLayoutBuilder expects analyzer in version >=3.0.0 and <4.0.0
  • hive_generator expects analyzer in version >=1.0.0 and <4.0.0

Any suggestions where I'm mistaken are gladly welcome.

CodePudding user response:

Right now nether hive_generator plugin have any upgrade then this version and nor yet_another_layout_builder has downgrade version. So to tackle these kinds of scenarios we have another method to add dependencies in Flutter which is dependency_overrides using this we can override some dependencies so that our app can use another version of the same dependency as well. So just add below code to your pubspecs.yaml file

dependency_overrides:
  analyzer: ^2.8.0

CodePudding user response:

please go and check in the official package documentation of yet_another_layout_builder and hive_generator, go to versions and test lower versions until you find the ones that don't wire such a message

  •  Tags:  
  • Related