VSCode Can't Find the PATH To the Flutter SDK
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:
- Open up Terminal. Run the following command: sudo nano /etc/paths
- Enter your password, when prompted.
- Go to the bottom of the file, and enter the path you wish to add.
- Hit control-x to quit.
- 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.
If you installed Flutter extension please restart VS_CODE and try it again. I already had the same problem.
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;
- Either edit the
.packages
file & set the path. - 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. - Restart VSCode & run
flutter pub get
This should resolve the issue.