Visual Studio Code Can't Run Flutter - looking at wrong dart version

223 Views Asked by At

I have created a new flutter Project, but when I run it on Visual Studio Code by clicking on "Start Debugging" the following errors pops up:

[button_test] flutter pub get
Running "flutter pub get" in button_test...                     
The current Dart SDK version is 2.17.6.

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

So I've double checked the dart version by entering dart --version. But this came back as 2.18.6

The funny thing is that if I enter flutter run on the Terminal, it works no problem. As I've installed the flutter and dart extension, I believe this is a problem with those extension? With that said, is there a way to fix which version of dart it's looking at?

Thanks

1

There are 1 best solutions below

0
Akashptl On

Step 1: Open terminal and Navigate to the flutter location

cd <flutter_path>

Step 2: Now enter the command

git checkout

You can find all the releases from this link https://docs.flutter.dev/development/tools/sdk/releases

Step 3: Now run flutter doctor -v command so flutter will download the stuff related to the particular version

flutter doctor -v

Once the flutter doctor command is successful you can go ahead and enjoy the version you wish