I just started working with Flutter, and can run my Flutter apps in Android Studio. I want to try Visual Studio Code, but when I click my run button, I get this in my Output window:
[Running] dart
"c:\MyStuff\Source\Flutter\hello_world\test\widget_test.dart"
'dart' is not recognized as an internal or external command,
operable program or batch file.
[Done] exited with code=1 in 0.199 seconds
My first thought was my Path environment variable, which I have mangled trying to get this to work. It looks like this:
%USERPROFILE%\AppData\Local\Microsoft\WindowsApps; c:\Flutter\bin;
c:\temp\flutter; c:\windows\system32;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
C:\temp\Flutter\bin\cache\dart-sdk.old1\bin
My c:\temp\Flutter directory looks like this:
https://i.stack.imgur.com/584fj.jpg
(I include that because I am a bit lost, and hoping someone will spot something I've done wrong.)
Does anyone have any ideas what I am doing wrong? This seems like it should just be basic setup, but I have obviously screwed it up. :(
EDIT:
Thanks for the response! I actually did that first thing. Flutter doctor gives me this:
[flutter] flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.5.1, on Microsoft Windows [Version
10.0.16299.547], locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK
28.0.2)
! Some Android licenses not accepted. To resolve this, run: flutter
doctor --android-licenses
[√] Android Studio (version 3.1)
[!] VS Code, 64-bit edition (version 1.25.1)
[√] Connected devices (1 available)
! Doctor found issues in 2 categories.
exit code 0
I don't know how to run Flutter doctor with a parameter (-v) in VSCode's command palette. Maybe that would give me more information. It seems to allow me only "canned" commands there. Do you know how I can run Flutter doctor with the -v parameter?
First of all, just place the sdk in an easy to reach place. mine is in the compressed directory of my downloads folder, works best for me this way. After extracting it locate the flutter_console.bat
file according to your screenshot it is right there in the directory shown by screenshot. Run the file.
Then go to environment variables in User variables modify path, and remove the other flutter directories and that dart directory you have put. put the whole path of the flutter directory for example mine is C: Users/UserName/Downloads/Compressed/flutter_windows_v0.5.1-beta/flutter/bin
restart computer for the path to be updated
After restart Go to vs code settings in the User Settings, add this line to it
"dart.flutterSdkPath": "C:\\Users\\UserName\\Downloads\\Compressed\\flutter_windows_v0.5.1-beta\\flutter\\bin",
note the backslashes in above This is pointing the editor to the location of the Sdk. Also go to extensions search or marketplace and install the dart and flutter plugins
Add the path of your Dart sdk into user/system environment variables.
Lets say my Flutter SDK path is :E:\Android\flutter\bin
Now my Dart path will be inside :E:\Android\flutter\bin\cache\dart-sdk\bin
So edit the PATH variable and add the value at the end after a semicolon:
E:\Android\flutter\bin\cache\dart-sdk\bin;
and restart the system and open cmd from windows and just simply run dart.
After restart In VS code go to New Terminal
and add the terminal as Powershell and run dart command.
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