VSCode dart analyzer stopped recognizing flutter/dart code

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.


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


I got this problem too then I reinstalled dart and flutter plugin from androod studio and it's fixed.