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.
Is there any way to solve this problem?
Thanks.
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.
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:
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;
.packages
file & set the path..packages
must've been already created. Copy that file & paste it in the root directory of your project.flutter pub get
This should resolve the issue.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With