'Dart File Association Messed Up In Android Studio Arctic Fox 2010.3.1
I have a Flutter project open in Android Studio Arctic Fox 2021.3.1 on a Mac.
Flutter is configured properly.
Somehow, I've have achieved the situation where a certain file, static_utils.dart, is not being treated as a dart file by Android Studio.
That is, it has the wrong icon next to it... which looks like a text file icon... and also the syntax checking is not working (that's the important part).
Already tried:
- File > Invalidate caches/restart
Interesting facts:
If I delete this file a re-create a new "dart file" of the same name, it still treats it as text(?)/not dart... but if I use a new name for the file, it works correctly.
Even files of the same problematic name in other projects are also losing their Dart association unless a new file is created with an unused name and the code is cut and pasted over.
So, it appears that there is dictionary somewhere in Android Studio that is establishing file association rules based on filename... and retaining the rules even when the file is deleted.
I can't find a way to fix this. I have tried this answer but it didn't work for me -- the file in question did not show up anywhere under any of the file types.
Solution 1:[1]
I finally solved it!
I've countered the same problem by creating a new file without its extension and accidentally registering the file type pattern. img1
Therefore, I just removed the wrong type's pattern away. img2
Go to File > Settings\Preferences > Editor > File Types > Find your file type (If you didn't remember, just find all of them from the beginning e.g .gitignore in the below image, and I found at Auto-detect the file by content) and then remove it!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Thinh Doan |

