Search code examples
androidflutterdartyamlpubspec

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


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?


Solution

  • 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!