Conflict between dependencies when adding a new one

Issue

These were my dependencies in my pubspec.yaml:

  dependencies:
   ...
   image_picker: ^0.8.4+2
   ...

And everything worked fine, but now I added this:

  dependencies:
   ...
   image_picker: ^0.8.4+2
   ...
   image_editor_pro: ^1.1.8

And running pub get I have this error:

Because image_editor_pro >=1.1.0 depends on image_picker ^0.7.4 and provauth depends on image_picker ^0.8.4+2, image_editor_pro >=1.1.0 is forbidden.
So, because provauth depends on image_editor_pro ^1.1.8, version solving failed.
pub get failed (1; So, because provauth depends on image_editor_pro ^1.1.8, version solving failed.)

I tried downgrading my version of image_picker but I get a new error:

Cannot open file, path = ‘C:\Users\loren\flutter.pub-cache_temp\dir60565baa\test\fixtures\invalid\n_structure_<.>.json’ (OS Error: Syntax of the name of the file, of the directory or of volume is not correct (This is my bad translation of the error).
, errno = 123)
pub get failed (66; , errno = 123))

What can I do to solve and use both the dependencies?

Solution

You can try to override the dependency so only one version is used for your project. Something like this:

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

But you need to thoroughly tested the library that depends on the overrided dependency to check if it not introducing you a new error.

See https://dart.dev/tools/pub/dependencies#dependency-overrides

Answered By – ישו אוהב אותך

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *