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
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<>>
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.
Make sure you didn't declare any nested generics and didn't finish the line with your var name like mine
Analyzing for infinite time. 😞
Future<List<>>
Now we are good 😃
Future<List<int>> getMyListOfInt();
Happened to me after upgrading to latest Flutter version (1.20.0). Closing and restarting VSCode fixed it for me.
you can follow these steps. It's work for me
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!
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.
com.microsoft.VSCode
com.microsoft.VSCode.ShipIt
Related
I think it has something to do with this warning I keep getting from dart sdk
Socket error: FileSystemException: Directory watcher closed unexpectedly, path =
'c:\Users\Saad\OneDrive\Documents\Scripts\mutanafisun'
I searched for a solution for it but found none.
this is my flutter doctor
[√] Flutter (Channel stable, 3.0.5, on Active code page: 1252
Microsoft Windows [Version 10.0.19044.1826], locale en-US)
• Flutter version 3.0.5 at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (4 weeks ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
Checking Java status is taking a long time...[√] Android toolchain - develop for Android
devices (Android SDK version 31.0.0)
• Android SDK at C:\Users\Saad\AppData\Local\Android\sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: C:\Program Files\Java\jdk-14\bin\java
• Java version Java(TM) SE Runtime Environment (build 14+36-1461)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Build Tools 2022 17.2.3)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
• Visual Studio Build Tools 2022 version 17.2.32526.322
• Windows 10 SDK version 10.0.19041.0
[!] Android Studio (not installed)
• Android Studio not found; download from
https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/windows#android-setup for
detailed instructions).
[√] VS Code (version 1.70.1)
• VS Code at C:\Users\Saad\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.46.0
This seems to be a bug in the current Dart/Flutter releases, however, it should not have any material affect on your app. You should be able to continue as normal:
When Flutter builds it modifies a lot of files on disk in a short space of time and this sometimes overflows the watcher and causes it to close. The server has code to handle this (it creates new watchers and reanalyzes from disk), however to resolve some other issues during the restart it creates some additional watchers which do not have error handling (and since the Flutter build may still be occurring, it's possible those will close for the same reason). It's not ideal that a Flutter build can touch enough files to overflow the watcher and require a restart like this, but I believe that's understood behaviour because the server has had to handle this before.
Here is a full discussion:
https://github.com/dart-lang/sdk/issues/49286
Also see confirmation that fix has been found but not yet released:
There is a bug in the current Dart/Flutter stable releases that can trigger this error during a build. [They] have recently fixed the issue in the Dart SDK, but it has not been released yet. The fix will show up in a future release of the Dart/Flutter SDK. Unfortunately [they] don't know of a temporary workaround.
https://github.com/Dart-Code/Dart-Code/issues/4077
In the image above you can see that the whole dart code is showing white lines and this happened after my laptop accidently turned off while I was running the code.
The first error it gave was corrupted .git/packed-ref file which i fixed but this one isn't going away, other file type is showing their repective color theme only the .dart file is doing this. and also dart analyzer isn't working too
//Flutter doctor -v
[√] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Version 6.3.9600], locale en-US)
• Flutter version 2.8.0 at D:\flutter\Sdk\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cf44000065 (8 weeks ago), 2021-12-08 14:06:50 -0800
• Engine revision 40a99c5951
• Dart version 2.15.0
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0-rc2)
• Android SDK at C:\Users\bright\AppData\Local\Android\sdk
• Platform android-31, build-tools 31.0.0-rc2
• Java binary at: C:\Program Files\Android\Android Studio1\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio1
• Flutter plugin version 44.0.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code (version 1.63.2)
• VS Code at C:\Users\bright\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.34.0
[√] Connected device (1 available)
• Edge (web) • edge • web-javascript • Microsoft Edge 97.0.1072.69
! Doctor found issues in 1 category.
I don't exactly know what the problem is, since it isn't showing me any error. Please what do i do?
I think there is something wrong with the Dart extension (perhaps some files are corrupt), but uninstalling/re-installing it does not remove the files from disk and re-download it.
I would try uninstalling the Dart extension, then go into your %USERPROFILE%\.vscode\extensions folder and delete any dart-code.dart-code folders, and then re-launch VS Code and re-install it.
If that doesn't solve it, please file an issue at https://github.com/Dart-Code/Dart-Code. Thanks!
The syntax of the dartcode in my flutter project is no longer being highlighted and cannot click the declarations or do autocomplete of code, like typing: StreamBuilder( and then click enter to create the widget for a streambuilder.
See example code below, where normaly, the different elements would be coloured:
This problem occured after I installed intelliJ, I did this because I needed to write some javascript for firebase functions.
Tried this so far, with no luck:
deleting android studio and re-install it.
invalidate caches and restart.
restart analyses server
checked that dart and flutter has the right paths under 'languages & frameworks'
created a new flutter project, here everything works just fine. but if i copy in my codebase the issue persists
Im using android studios latest version.
EDIT:
Apparently I have some issues after all with the plugins. But as seen in the picture, I've given the paths to both flutter and dart.
Its somehow related to intelliJ because when i click the links from the flutter doctor output it takes me to jetbrains website
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.3 20E232 darwin-x64, locale da-DK)
• Flutter version 2.2.3 at /Users/jeffmayn/Desktop/Development/flutter
• Framework revision f4abaa0735 (10 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/jeffmayn/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Library/Java/JavaVirtualMachines/jdk-15.0.1.jdk/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 15.0.1+9-18)
✗ Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[✓] Connected device (2 available)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 93.0.4577.63
! Doctor found issues in 2 categories.
Process finished with exit code 0
I think reinstalling Flutter and Dart plugin to Android Studio can help. Syntax highlighting is plugins' job.
The solution of yoppuyoppu worked for me, but as he mentioned, only for the selected files.
So here is a small addition that makes it work for all .dart files:
In the "Register New File Type Association" window you can change the File pattern to "*.dart".
And of course select Dart as shown.
That way all files ending with ".dart" will be associated with Dart.
In my case, only one file had such problem. And it turned out I screwed up the file type association of the file when I created it.
Fix was to reassociate the file with Dart.
Go to the menu bar >> File >> File Properties >> Associate with File Type...
And in the dialog that follows, pick Dart and click OK.
You can choose as many files as you like at any one time.
None of the suggested solutions worked out for me. What I did was then:
create a new flutter project.
setup dart and flutter plugins.
copy in all my code, files, assets, etc. from the old project to the new.
A new installation of flutter/dart went smoothly without issue .. running "flutter doctor -v" gives the following output:
$ flutter doctor -v
[✓] Flutter (Channel beta, v0.11.9, on Linux, locale en_AU.UTF-8)
• Flutter version 0.11.9 at /home/jedaa/bin/flutter
• Framework revision d48e6e433c (3 days ago), 2018-11-20 22:05:23 -0500
• Engine revision 5c8147450d
• Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
• Android SDK at /home/jedaa/bin/Android/sdk
• Android NDK location not configured (optional; useful for native
profiling support)
• Platform android-28, build-tools 28.0.2
• ANDROID_HOME = /home/jedaa/bin/Android/sdk
• Java binary at: /opt/android314/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-
b06)
• All Android licenses accepted.
[✓] Android Studio (version 3.2)
• Android Studio at /opt/android314
• Flutter plugin version 30.0.1
• Dart plugin version 181.5656
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-
b06)
[✓] IntelliJ IDEA Community Edition (version 2018.2)
• IntelliJ at /opt/idea
• Flutter plugin version 30.0.2
• Dart plugin version 182.5124
[✓] VS Code (version 1.29.1)
• VS Code at /usr/share/code
• Flutter extension version 2.20.0
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
and yet attempting to run the defalut starter app "flutter/material.dart" results in ... "Unable to locate a development device; please run 'flutter doctor' for information about installing additional components" ... irrespective whether i use Intellij or Visual Studio.
However,
$ flutter devices
1 connected device:
Pixel XL • HT69R0205363 • android-arm64 • Android 9 (API 28)
I have searched the web and found similar complaints .. but no solution. I was hoping that someone might be able to throw some light on this as I am sure it must be something simple and straight forward.
Visual Studio is a new installation but I have been using Intellij now for 6 months on a daily basis and rarely have issue with it .. especially one that i cannot fix. :)
Thank you in advance.
open Terminal in Android Studio or VS Code.
and writes this command :
flutter config --android-sdk <sdk-location>
SDK-location is your Path for SDK! for Example :
flutter config --android-sdk /home/sanaebadi/Pasport/programming/and_dev/sdk/sdk-tools-linux-3859397/
I had the same problem , then I tried this solution , and it helped me and my flutter app is running on my phone ..
all you need to do is install Android API level 29 (Android 9.0+ "Q")
go to Setting > Android SDK >SDK platform>Check Android 9+ and Press Apply button
I found this solution from github .. her is the link ..
Hope this help you
https://github.com/flutter/flutter/issues/22649#issuecomment-520472515
In Android Studio, ensure that the API level of your Project SDK (File->Project Structure) <= of the API level of your AVD.
I just getting with flutter. I have installed it along created a project successfully.
But when I try to run it fails.
Below is the output with flutter doctor -v
PS C:\android-app\flutter-app\flutter_first_app> flutter doctor -v
[√] Flutter (Channel master, v0.5.5-pre.9, on Microsoft Windows [Version 10.0.16299.461], locale en-US)
• Flutter version 0.5.5-pre.9 at C:\android-app\flutter
• Framework revision 587569337e (7 hours ago), 2018-06-13 00:02:21 +0200
• Engine revision a328531402
• Dart version 2.0.0-dev.60.0.flutter-a5e41681e5
[!] Android toolchain - develop for Android devices (Android SDK 28.0.0)
• Android SDK at C:\Users\Sreyah Admin\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.0
• ANDROID_HOME = C:\Users\Sreyah Admin\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
X Android license status unknown.
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[!] VS Code, 64-bit edition (version 1.24.0)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected devices (1 available)
• XT1706 • HKE63YLL • android-arm • Android 6.0 (API 23)
I have installed the Flutter extension.
I tried uninstall and install a couple of time, but still the same result.
I think there are two issues here:
Doctor says you don't have the extension
Your project doesn't run
1 Doctor says you don't have the extension
This is a bug I've just fixed. Seems like VS Code may have started lower-casing the extension folders recently, and our test for them was case sensitive. The fix is in master but hasn't made the beta channel (as of 22nd June 2018).
Note: This check doesn't affect anything else, as long as the extension is installed this is just an issue with the doctor output.
2. Your project doesn't run
This is probably not related to the doctor output if you can see the extension in VS Code. You haven't included any info on the reason your app doesn't run (does it give an error? what do you see?) so it's hard to guess; but if you can provide that info I can take a stab.
If you haven't already, it's also worth running the project from the command line with flutter run to see if it works there, to see whether the issue is specific to VS Code or something else with your setup.
If if works from the command line then I would recommend opening an issue on GitHub for the Dart-Code repo with more information and we can track it down from there.
Open your VS Code if you have it installed, if not you can still install it from the link. Flutter internally use Dart language to build a mobile app. So you need to install this extension
Then open this link "https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter" to install this extension.
After the installation run your flutter doctor -v to confirm.