Flutter image version issue

Issue

I have just upgraded my flutter version and now I am facing the following issue when I get the packages in pubsec.yml file:

Because every version of flutter_test from sdk depends on image 2.1.4 and Instant_Feedback depends on image ^2.1.9, flutter_test from sdk is forbidden.

So, because Instant_Feedback depends on flutter_test any from sdk,
version solving failed. pub get failed (1; So, because
Instant_Feedback depends on flutter_test any from sdk, version solving
failed.)

My pubsec.yml file

dependencies:
  flutter:
    sdk: flutter
  http: ^0.12.0+2
  shared_preferences: ^0.5.4+8
  firebase_messaging: ^6.0.3
  flutter_crashlytics: ^1.0.0
  firebase_core: ^0.4.2+1
  cupertino_icons: ^0.1.3
  device_calendar: ^1.0.0+2
  cloud_firestore: ^0.12.11
  auto_size_text: ^2.1.0
  flutter_expandable_menu: ^0.0.1
  webview_flutter: ^0.3.17
  flutter_spinkit: ^4.1.1+1
  get_it: 2.1.0
  bloc: ^0.15.0
  flutter_bloc: 0.21.0
  equatable: 0.5.1
  rflutter_alert: ^1.0.3
  expandable: ^3.0.1
  connectivity: ^0.4.6
  firebase_auth: ^0.15.1
  flutter_email_sender: ^2.2.1
  mockito: 4.1.1
  flutter_secure_storage: ^3.3.1+1
  image_picker: ^0.6.2+2
  async: any
  image: ^2.1.10
  image_crop: ^0.3.1
  flutter_cache_manager: ^1.1.3
  circular_profile_avatar: ^1.0.3
  package_info: ^0.4.0+12
  flutter_local_notifications: ^0.8.4+3
  flutter_webview_plugin: ^0.3.10
  url_launcher: ^5.2.7
  flutter_localizations:
    sdk: flutter
  flutter_cupertino_localizations: ^1.0.1


dev_dependencies:
  flutter_driver:
    sdk: flutter
  test: any

  ozzie: 2.0.1
  flutter_test:
    sdk: flutter
flutter:
  uses-material-design: true
  assets:
    - lib/app/assets/images/
    - lib/app/assets/flags/
    - lang/en.json
    - lang/de.json

Solution

Because every version of flutter_test from sdk depends on image 2.1.4 and Instant_Feedback depends on image ^2.1.9, flutter_test from sdk is forbidden.

I faced the same issue. Couldn’t find the specific reason for the flutter_test depending on a specific version of this image library. Maybe it’s an issue from the flutter side. So here are some workaround solutions:

  1. comment out the flutter_test dev_dependency.

    dev_dependencies:
    # flutter_test:
    # sdk: flutter

  2. set the required version.

    Instead of 2.1.12, I set the Image package version to 2.1.4 (as requested in the error message)

    image: ^2.1.4

  3. If more than one packages versions are noncompatible to each other, and you don’t know their exact compatible version, you can find it by setting both the conflicting dependencies to any, e.g.

    flutter_crashlytics: any
    firebase_core: any

    This will automatically figure out the compatible package version. Check these new compatible versions in pubspec.lock file, which will be auto-generated by running flutter package get.

    # Generated by pub
    # See https://www.dartlang.org/tools/pub/glossary#lockfile
    packages:
    flutter_crashlytics:
    ...
    version: "1.0.0"
    firebase_core:
    ...
    version: "0.4.2+1"

    Replace any with those correct versions.

    flutter_crashlytics: 1.0.0
    firebase_core: 0.4.2+1

Note: You should never leave your versions as any

Answered By – Alex Roy

Answer Checked By – Marie Seifert (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.