6

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:

example code

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

enter image description here

enter image description here

11
  • see if this helps: jetbrains.com/help/idea/annotation-processors-support.html Commented Sep 7, 2021 at 20:30
  • @Benyamin I also deleted intelliJ. Only using Android Studio now Commented Sep 7, 2021 at 20:35
  • almost no difference, check it. Commented Sep 7, 2021 at 20:35
  • 1
    You installed the plugins for flutter and dart already, right? Commented Sep 7, 2021 at 20:45
  • And is there anything useful if you type flutter doctor from the terminal? Commented Sep 7, 2021 at 20:46

6 Answers 6

2

I think reinstalling Flutter and Dart plugin to Android Studio can help. Syntax highlighting is plugins' job.

Sign up to request clarification or add additional context in comments.

5 Comments

I've tried that. If you look at my flutter doctor it says the plugins for dart and flutter is missing and that I can download them from jetbrains.. so somehow android studio is still thinking its using intelliJ. Don't know how to change this, so now I will backup my codebase and pull back to an recent commit before I installed intellij, then copy back the codebase. hopefully this will work
There is nothing wrong because Android Studio is already based on IntellijIDEA. This can be helpful for removing plugins.
now Ive tried removing all plugin like described in that link, still did not work. even tried completely removing all traces of android studio from my system, installing a fresh version and opening my project again. Same issue :/ starting to suspect its the 2020.3 version doing some weird stuff
Please provide additional details in your answer. As it's currently written, it's hard to understand your solution.
I got this issue after upgrading to New UI In Android Studio Giraffe. Finally this Solution Worked for Me...
2

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

enter image description here

And of course select Dart as shown.

That way all files ending with ".dart" will be associated with Dart.

Comments

1

It is related with Dart SDK. Delete the

flutter/bin/cache

folder and run dart --version

on zsh to download your correctly working dart sdk again.

Open your project and finally flutter pub get

1 Comment

this is the only working solution to me after 2 hous of debugging, thanks man
0

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.

Menu bar selection Dialog selection

Comments

0

dart analysis defines your syntax highlighting for custom method and packages so its server need to be running check this.

if its not working u may corrupted it with a cache clearing analysis_server.dart.snapshot file from the ~/flutter/bin/cache/dart-sdk/bin/snapshots

To solve that:

flutter upgrade

or

flutter upgrade --force

Comments

-8

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.