Home > other >  Conflicting ffi version between packages & failed to get dependencies in pubspec.yaml
Conflicting ffi version between packages & failed to get dependencies in pubspec.yaml

Time:10-18

Because tflite_flutter >=0.6.0 depends on ffi ^1.0.0 and file_picker 5.2.1 depends on ffi ^2.0.1, tflite_flutter >=0.6.0 is incompatible with file_picker 5.2.1. And because no versions of file_picker match >5.2.1 <6.0.0, tflite_flutter >=0.6.0 is incompatible with file_picker ^5.2.1. So, because untitled6 depends on both file_picker ^5.2.1 and tflite_flutter ^0.9.0, version solving failed. pub get failed (1; So, because untitled6 depends on both file_picker ^5.2.1 and tflite_flutter ^0.9.0, version solving failed.)

I try to get the pubspec.yaml of tflite_flutter (https://pub.dev/packages/tflite_flutter) and it seems to be conflicting with file_picker (https://pub.dev/packages/file_picker), is there any way to change the ffi version in the local pubspec.yaml instead of making pull request on tflite_flutter?

CodePudding user response:

In this case to you have 3 options:

  • bump version of the tflite_flutter if possible
  • downgrade version of the file_picker
  • use 'dependency_overrides' in your yaml file for ffi

CodePudding user response:

Try dependency override in pubspec.yaml first.

dependency_overrides:
  ffi: ^2.0.1

If it doesn't work, add both the conflicting dependencies in pubspec.yaml without specifying version like,

dependencies:
  tflite_flutter:
  file_picker:

It automatically selects the version that works without conflicts.

If it does work, in the pubspec.lock file, you can see the version it selected, like

bloc:
  dependency: transitive
  description:
    name: bloc
    url: "https://pub.dartlang.org"
  source: hosted
  version: "8.1.0"

Just add this version to pubspec.yaml file. This ensures you don't fetch different version whenever you run pub get.

This will work for now. But it is not always good idea to use the old version. So always look for the packages new version.

Hope it helps!

  • Related