Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

pub get fails with version solving failed after an SDK or package change

ErrorBecause 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.

  • Applies to Flutter 3.x, Dart 3.x
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 outdated
  2. 2Match what you see, then jump to its fix

    1. 1Because 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. 2A dependency requires a Flutter or Dart SDK newer than yoursA package needs a newer Flutter than the one installedFix
    3. 3The solver or the run step complains that a dependency does not support null safetyA dependency was never migrated to null safetyFix
    4. 4pub outdated says a package is constrained to a version older than a resolvable versionYour own constraint is older than a resolvable versionFix
    5. 5Two packages need incompatible versions of a third oneA temporary pin is needed while a package catches upFix

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.yaml

2Fix

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.0

3Verify

Fetch dependencies.

flutter pub get

Confirmed by dart.dev

Did this fix it?

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 --version

2Fix

Upgrade Flutter on your channel, or pick an older release of that package whose constraint fits.

flutter upgrade
flutter pub get

3Verify

Run the dependency check again.

flutter pub outdated

Confirmed by docs.flutter.dev

Did this fix it?

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 outdated

2Fix

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 get

3Verify

Run the app.

flutter run

Confirmed by github.com

Did this fix it?

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 outdated

2Fix

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 upgrade

3Verify

Run the tests.

flutter test

Confirmed by dart.dev

Did this fix it?

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 list

2Fix

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 get

Confirmed by dart.dev

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.