skip to Main Content

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

4

Answers


  1. Chosen as BEST ANSWER

    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.

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

    Login or Signup to reply.
  3. 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

    Login or Signup to reply.
  4. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search