pub get fails with version solving failed after an SDK or package change
Because app requires SDK version >=2.15.1 <3.0.0, version solving failed.Short answer
Version solving fails when no package version fits both your SDK and every other constraint. Run flutter pub outdated to see what blocks each package. Then raise the app's SDK range or upgrade Flutter, upgrade or replace packages that predate null safety, or relax an exact pin. An override is the last resort.
Fix it fast
1Find out which cause you have
Read the error from the bottom. It names the package and the constraint that cannot be met. Then list what is out of date.
flutter --version flutter pub outdated2Match what you see, then jump to its fix
- 1
Because app requires SDK version >=2.15.1 <3.0.0, version solving failedThe SDK range in pubspec.yaml is too narrow for a package you wantFix - 2
A dependency requires a Flutter or Dart SDK newer than yoursA package needs a newer Flutter than the one installedFix - 3
The solver or the run step complains that a dependency does not support null safetyA dependency was never migrated to null safetyFix - 4
pub outdated says a package is constrained to a version older than a resolvable versionYour own constraint is older than a resolvable versionFix - 5
Two packages need incompatible versions of a third oneA temporary pin is needed while a package catches upFix
- 1
What does the error look like?
Because app requires SDK version >=2.15.1 <3.0.0, version solving failed.
Cause 1 of 5
The SDK range in pubspec.yaml is too narrow for a package you want
1Check
Pub picks the newest package version whose SDK constraint works with your installed Dart SDK. An old upper bound in your environment section, like <3.0.0, keeps out packages that need Dart 3.
grep -n -A3 "^environment" pubspec.yaml2Fix
Set the SDK constraint to a range that includes the Dart version you really run, using caret syntax, then fetch packages again. Do not widen it past what your own code supports.
environment:
sdk: ^3.2.03Verify
Fetch dependencies.
flutter pub getConfirmed by dart.dev
Cause 2 of 5
A package needs a newer Flutter than the one installed
1Check
A Flutter constraint is met only when the Flutter SDK is at or above its lower bound. Compare it with your version.
flutter --version2Fix
Upgrade Flutter on your channel, or pick an older release of that package whose constraint fits.
flutter upgrade
flutter pub get3Verify
Run the dependency check again.
flutter pub outdatedConfirmed by docs.flutter.dev
Cause 3 of 5
A dependency was never migrated to null safety
1Check
Dart 3 and later does not support code without null safety, so a package that never migrated cannot be used. outdated shows which package is stuck and why.
flutter pub outdated2Fix
Move to a newer release of the package, or replace it with a maintained one. The old flag --no-sound-null-safety was only for mixed code on older toolchains, and it does not work on Dart 3.
flutter pub upgrade --major-versions
flutter pub get3Verify
Run the app.
flutter runConfirmed by github.com
Cause 4 of 5
Your own constraint is older than a resolvable version
1Check
The Resolvable column shows the newest version that works with everything else. If it is above what your constraint allows, your constraint is the blocker.
dart pub outdated2Fix
Edit the constraint in pubspec.yaml, then upgrade. Test the app afterwards, because a major version can have breaking changes.
dependencies:
path: ^1.9.0
# then
dart pub upgrade3Verify
Run the tests.
flutter testConfirmed by dart.dev
Cause 5 of 5
A temporary pin is needed while a package catches up
1Check
Find which package pulls in the third one.
dart pub deps -s list2Fix
As a last resort, force one version with dependency_overrides. Overrides are risky. Overrides in packages you depend on are ignored, and they are applied only to your own app. Put it in pubspec_overrides.yaml to keep it out of version control.
dependency_overrides:
transmogrify: '3.2.1'3Verify
Fetch and run the app. Remove the override when the packages agree.
flutter pub getConfirmed by dart.dev
How do I stop it coming back?
- Run flutter pub outdated at the start of each sprint instead of when the build breaks.
- Prefer caret constraints so patch and minor upgrades are picked up.
- Avoid packages with no recent release for new projects.
- Commit pubspec.lock for apps so every machine resolves the same versions.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- Qist BazaarA buy-now-pay-later marketplace built from a blank repo, now past 100K downloads on Google Play.
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
Related fixes
Mobile apps
AudioCache has no play method after updating audioplayers
The method 'play' isn't defined for the type 'AudioCache'.
Since audioplayers 1.0, AudioCache only turns asset files into local files and caches them.
2 causes, each with a fixMobile apps
Flutter Bloc throws that emit was called after the event handler completed
emit was called after an event handler completed normally.
Each on<Event> handler gets its own Emitter, and it stops working the moment the handler's returned Future completes.
2 causes, each with a fixMobile apps
analysis_options.yaml: the URI it includes can't be found
include_file_not_found
The analyzer reports include_file_not_found when the file named after include: in analysis_options.yaml does not resolve.
2 causes, each with a fixMobile apps
Dart error: the body might complete normally and return null for a non-nullable type
body_might_complete_normally
Dart found a path through your function or callback that reaches the closing brace without a return.
3 causes, each with a fixMobile apps
Dart throws ConcurrentModificationError while looping over a list
ConcurrentModificationError
Dart throws this when a collection changes size while something iterates it.
2 causes, each with a fixMobile apps
Dart cannot turn a compact timestamp like 20201101153000 into a DateTime
FormatException: Invalid date format
DateTime.parse accepts a subset of ISO 8601, and a time part must be introduced by T or a space.
2 causes, each with a fix