Main.dart is not recognising as as .dart file in android studio

Viewed 1103

In flutter project, main.dart is not recognizing as .dart file in android studio as shown in the screenshot attached. If I change the name of the file then it's recognizing.click here to view screenshot

3 Answers

Looks to me that the IDE is incorrectly associating your file as a Text file.

  1. Go to File -> Settings (Ctrl + Alt + S)
  2. Search for "File Types"
  3. Look for Text in the list
  4. Check if there is no entry for "main.dart" in the Text Type association.
  5. If so, remove it.

I managed to make it work was by doing the following (on Android Studio for MacOS):

  • on the main.dart file, right click and click on Override File Type
  • in the list that appears, select: Dart

I am facing the same problem, fixed it by right click the file and select the Override File Type menu, in the popup file type menu, select the dart or whatever the really file type you needed.

Related