Flutter with VSCode shows not installed even though its installs - visual-studio-code

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.

Related

Flutter / Dart syntax highlighting is not working

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.

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

I am unable to build my flutter web project

When trying to run flutter build web i get "build web" is not currently supported.
I had previous errors where i was stuck with Dart 2.5.0-dev.4.0.flutter-be66176534 and required 2.5.0 or higher, this has now been solved but i am unable to build my project.
flutter doctor -v
[√] Flutter (Channel stable, v1.9.1+hotfix.2, on Microsoft Windows [Version 10.0.18932.1000], locale en-GB)
• Flutter version 1.9.1+hotfix.2 at C:\src\flutter
• Framework revision 2d2a1ffec9 (8 days ago), 2019-09-06 18:39:49 -0700
• Engine revision b863200c37
• Dart version 2.5.0
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at C:\Users\germa\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
• All Android licenses accepted.
[!] Android Studio (version 3.4)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
[√] VS Code (version 1.38.1)
• VS Code at C:\Users\germa\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.4.1
I have tried
re-installing dart
re-installing flutter
re-installing Visual Studio code
copy file contents to a new web project (same error)
I couldn't find any information on what this is caused by and how to resolve it online
What can i do to resolve this error?
Please once do configure like below
flutter channel stable
flutter upgrade
flutter config --enable-web
cd into project directory
flutter create .
flutter run -d chrome
So currently you are at stable channel . You have to switch to the beta channel as flutter web is not at a stable channel right now. In order to make it working run the following commands in the terminal.
flutter channel beta
flutter upgrade
flutter config --enable-web.
After that restart your IDE and build the web app.
I was facing problem in flutter stable 2.0.2, by running
flutter create .
it was not creating web module, after upgrading it has started working. I guess my flutter web sdk had some issue so by fresh upgrade it got fixed.
if your are facing the problem
Ambiguous organization in existing files: {package_name1, package_name2}. The --org command line argument must be specified to recreate project.
you can use this command
flutter create --org package_name1 .
And
flutter run -d chrome
Just check whether you have used any plugins in pubspecs.yaml that is nonweb supportive.
you have to add web support to an existing app:
flutter create .
then try to
flutter build web

Unable to locate a development device; please run 'flutter doctor' .. but doctor checks out ok

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.

Android SDK is missing command line tools

I've installed flutter but when I run flutter doctor to verify the installation, I get:-
Android SDK is missing command line tools
I've doubled checked that the command lines are installed.
What do I need to do remove this error?
I've included the full flutter doctor -v output below:-
$ flutter doctor -v
[✓] Flutter (Channel beta, v0.3.1, on Mac OS X 10.13.4 17E202, locale en-AU)
• Flutter version 0.3.1 at /Users/chris/flutter
• Framework revision 12bbaba9ae (2 weeks ago), 2018-04-19 23:36:15 -0700
• Engine revision 09d05a3891
• Dart version 2.0.0-dev.48.0.flutter-fe606f890b
[!] Android toolchain - develop for Android devices
• Android SDK at /usr/local/Caskroom/android-platform-tools/27.0.1
• Android NDK location not configured (optional; useful for native profiling support)
• ANDROID_HOME = /usr/local/Caskroom/android-sdk/3859397
✗ Android SDK is missing command line tools;
• Try re-installing or updating your Android SDK,
visit https://flutter.io/setup/#android-setup for detailed instructions.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.3, Build version 9E145
• ios-deploy 1.9.2
• CocoaPods version 1.5.0
[✓] Android Studio (version 3.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 24.1.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] IntelliJ IDEA Ultimate Edition (version 2018.1.2)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 24.1.2
• Dart plugin version 181.4668.60
[!] Connected devices
! No devices available
! Doctor found issues in 2 categories.
On Android Studio open SDK Manager.
Go to SDK Tools tab.
Check if Android SDK Command-line Tools is checked. If not, check and apply the changes.
For some reason, after updating flutter and Android Studio, I got this error too. Seems like some new requirement that for some reason wasn't automatically installed.
This fixed it for me.
I think ANDROID_HOME and ANDROID SDK should be pointing to the same path and that is the SDK's root directory.
In my .bashrc (on LINUX), following are
export ANDROID_HOME=/home/myname/Android/Sdk
export PATH=/home/myname/Android/Sdk:$PATH
export PATH=/home/myname/Android/Sdk/platform-tools:$PATH
export PATH=/home/myname/Android/Sdk/tools:$PATH
export PATH=/home/myname/Android/ndk-build:$PATH
Just solved the problem. Here are my system settings:
System variable ANDROID_SDK_ROOT points to my Android SDK dir
In system Path variable, I have sdk/tools, sdk/platform-tools, and /flutter-dir/bin
Also make sure you don't have dulplicated directories. I previously downloaded another platform-tools and add it to Path, so I had to delete it and use the sdk's one.
After changing those things, I close the flutter cmd windows and run flutter doctor on PowerShell. Worked like a charm!
Please download the latest sdk build-tools to solve the problem of Android SDK is missing command line tools