Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter, Visual studio code project stuck on Analyzing

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

like image 236
Rami Ibrahim Avatar asked Apr 01 '20 17:04

Rami Ibrahim


2 Answers

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.

like image 60
SriDatta Yalla Avatar answered Oct 21 '22 02:10

SriDatta Yalla


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

like image 10
loki Avatar answered Oct 21 '22 00:10

loki