简体   繁体   中英

VSCode dart analyzer stopped recognizing flutter/dart code

I have been using VSCode for flutter development without issue, then today all of a sudden the dart analyzer is complaining that the majority of the classes are undefined, or targets do not exists.

Has anyone seen this before?

I have restarted VSCode, restarted computer, uninstalled flutter/dart plugins, ran flutter doctor with no issues...I am out of ideas.

VSCode Issues

Go to pubspec.yaml , right click and do Get Packages . It seems to work for me all the time.

The issue might be caused by VSCode struggling to find the Dart SDK installation path, even if it's in your Windows PATH.

To fix, just give the Dart extension an explicit reference to your SDK installation(s) using the extension settings ([Ctrl + ,], type 'Dart:') or by directly editing settings.json ([Ctrl + Shift + P], type 'settings.json', [Enter]).

If you have both Flutter and the full Dart SDK installed, add both listings:

"dart.sdkPaths": [
  "C:\\Program Files (x86)\\Dart\\dart-sdk\\bin",
  "C:\\Program Files (x86)\\Flutter\\bin\\cache\\dart-sdk\\bin",
],

If you have only one installed (most commonly just Flutter), you can just add that one:

"dart.sdkPath": "C:\\Program Files (x86)\\Flutter\\bin\\cache\\dart-sdk\\bin",

Bonus bit: The multiple-SDK settings are great (and in fact intended) when developing different projects requiring various SDK versions. I find this is especially useful when working on multiple projects over several months or even years, especially considering how rapidly and regularly both Dart and Flutter are changing and maturing at present.

Another approach can be.. to delete the dart SDK (the cache folder under the bin dir of flutter SDK). And use the cmd as admin to re download the sdk, by running flutter doctor.

我也遇到了这个问题,然后我从 androod studio 重新安装了 dart 和 flutter 插件,它已经修复了。

I've got something wrong options setting in my Vscode Dart Dev Tools auto open when Run Flutter app. I want to close VsCode da

This was an issue with the VS Code "Laravel blade spacer" extension. Once I removed the add on, I no longer had the problem

For me, de-installing then re-installing VS Code did the trick !

I came to that conclusion after talking to someone on the Dart/Flutter Extension server on Discord.

在 Discord 上获得帮助

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM