1

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

jeffmayn
  • 1,785
  • 2
  • 9
  • 22

4 Answers4

1

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

  • 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 – jeffmayn Sep 07 '21 at 22:14
  • There is nothing wrong because Android Studio is already based on IntellijIDEA. [This](https://stackoverflow.com/questions/23537065/where-is-the-plugin-folder-for-android-studio-on-mac/33140255) can be helpful for removing plugins. – Ekrem Kamaz Sep 07 '21 at 23:02
  • 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 – jeffmayn Sep 08 '21 at 00:10
  • Please provide additional details in your answer. As it's currently written, it's hard to understand your solution. – Community Sep 08 '21 at 01:34
1

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.

Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Jamil Mammri
  • 71
  • 1
  • 4
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

yoppuyoppu
  • 480
  • 4
  • 13
-2

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.
jeffmayn
  • 1,785
  • 2
  • 9
  • 22