Reputation: 2755
I have a flutter project I can run with no problems using git terminal and flutter command: flutter run
but I have been facing this problem recently when I try to open the same project using visual studio code,
once vs code starts, It tries to analyze the project for dart code errors. the procedure usually takes a relatively short time (a minute or so) but now It takes forever and I don't know why.
I tried to do flutter clean
on my project, but It did not solve it. also tried flutter pub get
, still not solving the problem. It is very strange because this is only happening when using visual studio code to open that particular project.
here is a log of flutter doctor -v
command :
C:\Users\Rami>flutter doctor -v
[√] Flutter (Channel beta, v1.15.17, on Microsoft Windows [Version 10.0.18363.720], locale en-US)
• Flutter version 1.15.17 at D:\Flutter\sdk
• Framework revision 2294d75bfa (4 weeks ago), 2020-03-07 00:28:38 +0900
• Engine revision 5aff311948
• Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at D:\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_SDK_ROOT = D:\Android\sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.43.2)
• VS Code at C:\Users\Rami\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.8.1
[√] Connected device (3 available)
• SM A520F • 192.168.8.80:5555 • android-arm64 • Android 8.0.0 (API 26)
• Chrome • chrome • web-javascript • Google Chrome 80.0.3987.162
• Web Server • web-server • web-javascript • Flutter Tools
• No issues found!
Your feedback is appreciated, Thank you
Upvotes: 15
Views: 11036
Reputation: 1
try to clean .analysis-driver
dir
rm -rf ~/.dartServer/.analysis-driver/*
and restart visual studio code.
Upvotes: 0
Reputation: 2311
I solved it like here. Enable dart.previewLsp
in your settings.
Ctrl + , and enter dart.previewLsp
.
Also the problem pops up when I code nested generic types. eg. Future<Either<X, Y>>
.
I avoid this as much as possible. You just need to copy the type from another line or use a snippet. Or code it from inside out.
Update
It seems the problem is fixed in recent versions of Dart. Just update your dart installation. Or avoid empty type declarations in generics. eg, Future<List<>>
Upvotes: 10
Reputation: 1706
Make sure you didn't declare any nested generics and didn't finish the line with your var name like mine
Future<List<>>
Future<List<int>> getMyListOfInt();
Upvotes: 1
Reputation: 866
I know this is too late, but I believe this helps any one stuck with this problem. In my case this is due to a syntax error. I tried commenting most recently edited files and restarted VSCode
then this annoying analyzing thing stopped.
Upvotes: 5
Reputation: 1562
This issue should be cache-related. You could try removing(do a backup just in case) all visual studio cache-related folders here ~/library/caches, then restart VS and you should be good to go.
This is the naming convention for VS cache folders.
Upvotes: 0
Reputation: 8646
Turn Analyzer logs on and see on what file its slow/stuck, sometimes that file has syntax error that is not handled by analyzer properly (how to turn analyzer logs on). First column in logs are your system's milliseconds since epoch.
Also enabling dart.previewLsp
as mentioned by @loki would help.
Another also, double check that your are not out of memory, the analyzer could be very hungry!
Upvotes: 0
Reputation: 347
Happened to me after upgrading to latest Flutter version (1.20.0). Closing and restarting VSCode fixed it for me.
Upvotes: 0