I'm having this issue when I've added http dependency in my flutter project. Can anyone please help me with it?

enter image description here


Solution 1: flarkmarup

Can you please provide the dependencies in your pubspec.yaml? It looks like your app depends on at least http 0.12.0 but flutter_test specifically requires http 0.11.3+17 (an older version) which makes it fail.


Solution 2: Rahul Sharma

You have provided or trying to use http: ^0.12.0 dependency on implementing API calls in pubspec.yaml file but flutter_test will require http: ^0.11.3+17. That's why it fails. Please replace

dependencies:
  flutter:
    sdk: flutter
  http: ^0.12.0

with

dependencies:
  flutter:
    sdk: flutter
  http: ^0.11.3

Hope it will help you out.


Solution 3: live-love

If you get the message:

Because every version of flutter_test from sdk depends on...

It means flutter_test depends on a dependency with version lower than you specified in another dependency.

To solve this, open pubspec.yaml, and remove the version number of the problem dependency:

Example:

Change

  archive: ^2.0.13 --> remove this number

To:

  archive: 


Solution 4: Hai nguyen thanh

In my case, I somehow deleted sdk: flutter:

dependencies:
  flutter:
    sdk: flutter


Solution 5: spyk3x

I was facing a similar error. I solved it by removing all the version numbers from the dependencies: section in pubspec.yaml.

So, if my pubspec.yaml looked like this before:

dependencies:
  freezed_annotation: ^0.14.3

I changed it to this:

dependencies:
  freezed_annotation:

I'm assuming this fetches the latest "possible" version of each package.


Solution 6: Konstantin Kozirev

If your app doesn't have too many dependencies that could broke, you can try to upgrade your Flutter version: flutter upgrade. It most probably will fix this problem. But always be sure to understand that your app might break at unexpected places. So you're fine if:

  • either you're doing it for small app
  • or it's big app at work and it has extensive tests that will tell you something has broken
  • if big app without tests, be sure to test every important place of the app, where dependencies are being used


Solution 7: Oleksandr

In my case IDE referred to an an older version of dart because of fvm. Seems like 'run' button called fvm flutter run, but not flutter run as I expected. After I deleted fvm folder from the project the problem has gone.


Solution 8: Prudvangar

Change depending attributes version inside pubspec.yaml if it says depands on http than change http version or if it says depands on collection than change collection version.


Solution 9: Pankaj Gupta

Try to change the dependency version that you were added in your pubspec.yaml file don't use the current or latest version try some previous versions of dependency.

for ex - if you are using latest sqflite version then chnage to previous version of that and then re-run your whole project.