Visual Studio程式码:找不到dart [英] Visual Studio Code: dart not found

查看:106
本文介绍了Visual Studio程式码:找不到dart的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Flutter,可以在Android Studio中运行Flutter应用程序.我想尝试使用Visual Studio Code,但是当我单击运行按钮时,会在输出"窗口中看到它:

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

我的第一个想法是我的Path环境变量,为了使它正常工作,我已经对其进行了修改.看起来像这样:

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

我的c:\ temp \ Flutter目录如下:

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. :(

感谢您的回复!我实际上是做第一件事的. Flutter医生给我这个:

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

我不知道如何在VSCode的命令面板中使用参数(-v)运行Flutter doctor.也许那会给我更多信息.似乎只允许我执行罐装"命令.您知道如何使用-v参数运行Flutter doctor吗?

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?

推荐答案

首先,只需将sdk放在容易接近的地方即可.我的文件夹位于我的下载文件夹的压缩目录中,这种方式对我来说效果最好.解压缩后,根据您的屏幕快照找到flutter_console.bat文件,该文件就在屏幕快照显示的目录中.运行文件. 然后转到用户变量修改路径"中的环境变量,并删除其他flutter目录和您已放入的dart目录.将flutter目录的整个路径放入例如我的C: Users/UserName/Downloads/Compressed/flutter_windows_v0.5.1-beta/flutter/bin 重新启动计算机以更新路径

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

重新启动后,转到用户设置"中的"vs代码设置",在其中添加此行

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",

注意上面的反斜杠 这将编辑器指向SDK的位置.另外,请转到扩展程序搜索或市场并安装dart和flutter插件

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

这篇关于Visual Studio程式码:找不到dart的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆