pub get says the SDK lower bound must be 2.12.0 or higher
The lower bound of "sdk: '>=2.1.0 <3.0.0'" must be 2.12.0 or higher to enable null safety.Short answer
Dart 3 only runs sound null safety, so any package whose sdk constraint starts below 2.12.0 is refused. Find whether the constraint is in your own pubspec.yaml or a dependency's. Migrate your code to null safety, or upgrade the dependency to a release that supports it.
Fix it fast
1Find out which cause you have
Read the package name in the error. If it is your own app, the constraint is in your pubspec.yaml. If it is another package, find who depends on it.
dart pub get dart pub deps | head -602Match what you see, then jump to its fix
- 1
The error names your own package, and pubspec.yaml has sdk: '>=2.1.0 <3.0.0' or similarYour own pubspec.yaml still has a pre-null-safety constraintFix - 2
The error names a package from pub.dev that you did not writeA dependency was never updated for null safetyFix - 3
The language version must be >=2.12.0, or Library doesn't support null safetyA file or package opts out with an old language versionFix
- 1
What does the error look like?
The lower bound of "sdk: '>=2.1.0 <3.0.0'" must be 2.12.0 or higher to enable null safety.The language version must be >=2.12.0Library doesn't support null safety
Cause 1 of 3
Your own pubspec.yaml still has a pre-null-safety constraint
1Check
Open the environment section of the project's pubspec.yaml and read the sdk line.
grep -n -A3 '^environment' pubspec.yaml2Fix
Dart 3 cannot run code that is not null safe. Migrate the app with a Dart 2.19 SDK (the migration tool was removed in Dart 3), then raise the lower bound to 2.12.0 or higher.
environment:
sdk: '>=3.0.0 <4.0.0'3Verify
Run pub get and the analyzer.
dart pub get
dart analyzeConfirmed by dart.dev
Cause 2 of 3
A dependency was never updated for null safety
1Check
Find which dependency pulls it in and whether a newer version exists.
dart pub deps
dart pub outdated2Fix
Upgrade first. If that is not enough, allow major version upgrades, then fix what the analyzer reports. If a package has no null safe release, replace it.
dart pub upgrade
dart pub upgrade --major-versions
dart analyze3Verify
pub get resolves and the analyzer is clean.
dart pub get && dart analyzeConfirmed by dart.dev
Cause 3 of 3
A file or package opts out with an old language version
1Check
Search the code for a language version comment at the top of files, and for a languageVersion override in package config.
grep -rn "@dart" lib test bin 2>/dev/null2Fix
Remove the override and make the file null safe; a language version below 2.12 is not accepted in Dart 3.
// delete lines such as:
// @dart=2.93Verify
Analyze the project again.
dart analyzeConfirmed by dart.dev
How do I stop it coming back?
- Keep dependencies current with dart pub outdated before each Flutter upgrade.
- Before choosing a package, check on pub.dev that it supports Dart 3.
- Set a lower bound of 3.0.0 or higher in new projects.
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
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.
Version solving fails when no package version fits both your SDK and every other constraint.
5 causes, each with a fixMobile 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 fix