Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Can't Find the PATH To the Flutter SDK

I just tried to execute Flutter: New Project, but it shows an error that could not find a flutter SDK. I've ensured to complete all of the requirements from the flutter doctor.

enter image description here

enter image description here

Is there any way to solve this problem?

Thanks.

like image 326
baimWonk Avatar asked Jul 02 '19 04:07

baimWonk


People also ask

How do you add a flutter SDK in VS code?

Start VS Code. Invoke View > Command Palette…. Type “install”, and select Extensions: Install Extensions. Type “flutter” in the extensions search field, select Flutter in the list, and click Install.


4 Answers

On macOS this was solved by following these steps.

First find where you downloaded the flutter sdk (Can be downloaded from here). It should be in your downloads folder unless you selected somewhere else.

Next:

  1. Open up Terminal. Run the following command: sudo nano /etc/paths
  2. Enter your password, when prompted.
  3. Go to the bottom of the file, and enter the path you wish to add.
  4. Hit control-x to quit.
  5. Enter “Y” to save the modified buffer.

If the sdk is downloaded into your Downloads folder, your path to add should be /Users/yourusername/Downloads/flutter/bin

Lastly, quit and restart your terminal windows and VS Code. After restarting, both apps should recognize flutter and running flutter doctor should now work.

like image 78
Casey Schneider Avatar answered Oct 21 '22 14:10

Casey Schneider


If you installed Flutter extension please restart VS_CODE and try it again. I already had the same problem.

like image 25
ant_dev Avatar answered Oct 21 '22 12:10

ant_dev


The thing is VSCode looks for .packages file in your Flutter project this file contains path to your Flutter SDK & some other metadata. You're getting this error because either the .packages file is missing or either the path to Flutter SDK in .packages file contains some discrepancies.

To resolve it, you can;

  1. Either edit the .packages file & set the path.
  2. Or if you already have a working Flutter project then a .packages must've been already created. Copy that file & paste it in the root directory of your project.
  3. Restart VSCode & run flutter pub get

This should resolve the issue.

like image 22
Mahesh Jamdade Avatar answered Oct 21 '22 14:10

Mahesh Jamdade


For Linux Users

For future visitors :)

I had the same problem, in my Terminal flutter doctor or in general flutter was recognized, but VSCode couldn't recognize my SDK location so flutter doctor for instance didn't work.

The first thing to do is to follow the steps in flutter documentation: Flutter Doc

If it didn't work, change the environment variables directly.

sudo nano /etc/environment

Now add the location of the bin folder of your flutter SDK, The folder that you downloaded from here.

For example, you extracted it here: /Home/User/Software

Add /Home/User/Software/flutter/bin to the PATH variable. Paths are separated by a colon(:)

After a few solutions I tried, this one worked.

like image 5
NoobN3rd Avatar answered Oct 21 '22 14:10

NoobN3rd