Flutter / Dart syntax highlighting is not working - flutter

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.

Related

Flutter VS code plugin stuck Waiting for connection from debug service on Chrome

I am using VS Code for Flutter developement since a long time and up until now, launching the web version from VS code has worked just fine. However, similar to what others have posted I now get a "Waiting for connection from debug service on Chrome...".
The Chrome window opens but the URL just says: "http://localhost:57698/" and the page is white.
If I click reload, the URL changes to "http://localhost:57698/#/" and the page loads correctly. This seem to match other peoples experience for this problem, that hot reloading or similar loads the page.
If I launch the web version from the command line with: "flutter run -d chrome" it also works fine. It is only when launching from VSCode it no longer works (and it has been ok for 2 years). I have tried to restart the whole computer as well as Chrome and VS code and I have done flutter clean, still the same. I have also tested on 2 different computers, no change. Is there some magic thing in Chrome that can get stuck or what could have happened?
My flutter doctor says that all is ok:
[✓] Flutter (Channel stable, 2.10.5, on macOS 13.2 22D49 darwin-arm, locale en-ES)
• Flutter version 2.10.5 at /Users/johanlantz/development/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (10 months ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/johanlantz/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.1)
• 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
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7772763)
[✓] VS Code (version 1.74.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.58.0
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Downgrading the dart and flutter VS code plugins from 3.58.0 to 3.56.0 fixed this (on two separate MacBooks with the same issue).
The latest version of the plugin switched to a new API (because an old API is being removed). Unfortunately when running on the web, it appears as if the new API is available (the VM Service version number is high enough), but the API is unfortunately not actually available.
A fix is on the way - you can get it early by switching to the Pre-Release version of the extension:

How to fix Chrome showing an empty / transprarent window for a Flutter web app on Linux?

When I run a Flutter web app in Chrome using Android Studio I only get an empty / transparent window on my Linux Mint 20.2 system.
empty / transparent chrome window of flutter web app
I have already tried reinstalling Chrome, which did not help. I have tried different Flutter projects including a fresh demo project (with web support), but the transparent screen shows up regardless. The same result shows up when I run flutter run -d chrome.
Anyone know how to fix this?
These are the results of flutter doctor -v:
flutter doctor -v
[✓] Flutter (Channel stable, 2.10.3, on Linux Mint 20.2 5.14.0-1032-oem, locale en_US.UTF-8)
• Flutter version 2.10.3 at /home/janik/snap/flutter/common/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 7e9793dee1 (5 weeks ago), 2022-03-02 11:23:12 -0600
• Engine revision bd539267b4
• Dart version 2.16.1
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /home/janik/Android/Sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /opt/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Android Studio (version 2021.1)
• Android Studio at /opt/android-studio
• Flutter plugin version 66.0.1
• Dart plugin version 211.7811
• Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.2)
• IntelliJ at /opt/idea-IU-203.7148.57
• 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
[✓] VS Code (version 1.66.1)
• VS Code at /usr/share/code
• Flutter extension can be installed from:
🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[✓] Connected device (1 available)
• Chrome (web) • chrome • web-javascript • Google Chrome 100.0.4896.75
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
this seems like an issue with the latest chrome update so I expect this to be fixed soon, meanwhile as a workaround what it worked for me and I suggest you do is to use chromium instead, which works.
Install chromium and find its executable which chromium, for me is use/bin/chromium and the version of chromium installed is: Version 83.0.4103.116 (Developer Build) built on Debian bullseye/sid, running on Debian bullseye/sid (64-bit), I am running Pop O.S 20.04, Dart 2.16.1 • DevTools 2.9.2, Flutter 2.10.2 • channel stable.
In the terminal where you will run the flutter app export a variable pointing to chromium: export CHROME_EXECUTABLE=/usr/bin/chromium, now you can run:
flutter run -d chrome and it will actually use chromium which renders the window properly.
I would expect this to be fixed soon, I will open an issue on the flutter repo if it's not there yet.
Good luck.
I don't have answer, only similar problem. Mint 20.2 Ryzen 3 2200G with Radeon Vega Graphics. Transparent window in Chrome using Android Studio AND ALSO in Visual Studio Code, even when creating a new (demo) project without any own code. But Pixel mobile emulator works, no problem in 'virtual' phone!! So, is this chrome-related problem? This problem emerged a few weeks ago.
I had similar issue but clearing Chrome’s cache worked like a charm

Unable to find bundled Java version. MacBook Air M1

I was using flutter on MacBook Pro with intel. It was working fine. Now I switch to MacBook Air with M1 chip. I get error Unable to find bundled Java version. How can I fix it pleas?
flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.2 20D64 darwin-arm, locale
en-KW)
• Flutter version 2.2.3 at /Users/mac/FlutterDev/flutter
• Framework revision f4abaa0735 (5 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 31.0.0)
• Android SDK at /Users/mac/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Library/Internet
Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.2
[✓] 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)
• macOS (desktop) • macos • darwin-arm64 • macOS 11.2 20D64 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.131
! Doctor found issues in 1 category.
I fix it by changing Contents folder location.
from
/Applications/Android Studio Preview.app/Contents/jre/Contents
to
/Applications/Android Studio Preview.app/Contents/jre/jdk/Contents
after close the android studio preview I face a problem with start it again.
but in general flutter doctor works with no Issues.
I had the same problem and solved it this way
cd /Applications/Android\ Studio.app/Contents/jre
ln -s /Library/Java/JavaVirtualMachines/jdk-16.0.1.jdk jdk
flutter doctor -v
enter image description here
I had the same problem a few days ago when I installed Android Studio for ARM64, I noticed that JDK from Oracle right now was running in x64. Looking in the web I found that you can install a native JDK for M1.
So basically the way that I found to solve your problem of the best way was installing JDK 15 arm64 from Azul
It improves a lot the compiler time for Android app's.
about ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio.
I have another environments. But you can think by use my answer.
In my opinion, you need to install JDK(Java development Kit).
If you can use Visual studio extensions or android studio plugin(i don't know mac environment), find Java extension pack for installation JDK(this is on visual studio)and install. You have to select JAVA Path correctly. If you select it on install process, you don't need to choose Path process individually. You can see this path on System variable Path as JAVA_HOME named automatically. not user path.
I hope your flutter is well
First of all, check what's going on with your JAVA_HOME:
echo $JAVA_HOME
I assume in your case you would already have it set correctly, so it should appear in a path like this (the jdk version may vary):
/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
If it the path looks the same (or same with different java version), and you have also checked "where java", "java -version" etc, to make sure that the terminal recognises your java well and there is no other obvious java issue, that means that the only thing you need to do is to run these commands:
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
Now if you run flutter doctor -v, you should see no java errors and something like this instead of the previous error:
• Java binary at: /Applications/AndroidStudio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
And no more errors :)
Hope this helps! It definitely solved the issue for me after switching to an M1 MacBook Air and upgrading the AndroidStudio to ArcticFox 2020.3.1 Patch 1).

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