'Error: Because project requires SDK version >=2.16.2 <3.0.0, version solving failed

I just tried to reactivate an old project, but it doesn't work.

I get this massage in my "output":

Because random_number requires SDK version >=2.16.2 <3.0.0, version solving failed.
pub get failed (1; Because random_number requires SDK version >=2.16.2 <3.0.0, version solving failed.)
exit code 1

But I already tried fluttter update

This is the output I get for flutter --version:

PS C:\Users\Simon\Desktop\Simon\Programmieren\App Entwickeln\Projekte\random_number> flutter --version
Flutter 2.10.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision c860cba910 (12 days ago) • 2022-03-25 00:23:12 -0500
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2

And this is what I have in my pubspec.yaml:

environment:
  sdk: ">=2.16.2 <3.0.0"

Does anyone know where I have made my mistake?



Solution 1:[1]

I have an idea, if your project is relatively small, then just copy the code files from your old project to your new one, Ctrl + C and Ctrl + V, it will take 10 minutes at most, I can't guess how old the version of your previous project is, so try my method above, it will most likely help.

Solution 2:[2]

the same mistake as you, update fluter to 2.10.5,it is solved.

C:\Users\zdz\fvm\default>flutter --version
Flutter 2.10.5 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 5464c5bac7 (4 weeks ago) • 2022-04-18 09:55:37 -0700
Engine • revision 57d3bac3dd
Tools • Dart 2.16.2 • DevTools 2.9.2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Legend5366
Solution 2