I'm having this issue when I've added http dependency in my flutter project. Can anyone please help me with it?
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:
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.
I encountered this error when trying to update the collection package.
My error:
Because butler_labs depends on flutter from sdk which depends on collection 1.17.1, collection 1.17.1 is required.
So, because butler_labs depends on collection ^1.17.2, version solving failed.
The solution was to run flutter update-packages --force-upgrade
which updated the dependencies in my local instance of Flutter. This command is mentioned in the official docs.
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.
In my case, I somehow deleted sdk: flutter
:
dependencies:
flutter:
sdk: flutter
sdk: flutter
mean? –
Offing 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.
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.
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.
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
Let's say the matcher package has encountered the following issue, which is the real case I suffered in the past:
Because matcher >=0.12.15 depends on test_api ^0.5.0 and every version of flutter_test from sdk depends on test_api 0.4.16, matcher >=0.12.15 is incompatible with flutter_test from sdk.
So, because myapp depends on both flutter_test from sdk and matcher ^0.12.15, version solving failed.
Simply run three commands subsequently:
flutter pub remove matcher
flutter pub add --dev matcher
flutter pub get
Finally there is a line change in pubspec.yaml
:
# before
matcher: ^0.12.15
# after
matcher: ^0.12.13
And myapp
can be run successfully using the above solution to upgrade flutter in channel stable, and upgrade flutter pub packages:
# upgrade flutter in channel stable
flutter channel stable
flutter upgrade
# upgrade flutter pub packages
flutter pub outdated
flutter pub upgrade
Because flutter_cab depends on flutter_google_places_hoc081098 ^1.2.0 which depends on http ^0.13.4, http ^0.13.4 is required. So, because flutter_cab depends on http ^1.2.0, version solving failed. I am facing this issue
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.
run flutter upgrade
. This problem occurs because your library is using the SDK version.
Remove the Flutter package clear installation cache and then install the Flutter package.
change in pubspect.yaml your http package:
dependencies:
flutter:
sdk: flutter
...
http: 0.12.0
to :
dependencies:
flutter:
sdk: flutter
...
http: any
© 2022 - 2025 — McMap. All rights reserved.