Visual Studio Code adding 'prefix0' in Flutter
Solution 1
The issue is caused by there being one or more duplicates of class names. Check that you do not have classes with the same name imported that may conflict with each other.
Solution 2
It's a bug in Dart Code that happened because it failed to understand another import already exported the class used.
A typical example is, flutter/material.dart
was already imported. But by typing Widget
, it'd import flutter/widget.dart
and with a prefix.
https://github.com/Dart-Code/Dart-Code/issues/1847
This has been fixed. Upgrading your Dart Code and flutter SDK should fix the issue.
Pyth0nGh057
Updated on December 13, 2022Comments
-
Pyth0nGh057 over 1 year
I have recently switch from Android Studio to VS Code to work on my Flutter projects but I have an issue with it.
VS Code keeps adding "prefix0." before all classes as soon as I am using auto-completion and I didn't find a way to get rid of it.
I have seen that some VS extensions for CSS can auto-prefix some parts of code but I do not have any CSS extensions.
Thanks
-
F-1 over 4 yearsWhen I came across this issue it was because I had classes with the same name. It does this to avoid conflicts
-
Pyth0nGh057 over 4 yearsOh yes thanks ! I had the same
import
twice. -
F-1 over 4 yearsGreat since that was the problem I've posted it as an answer
-
-
Rémi Rousselet over 4 yearsThat's usually not the issue. It's a bug in Dart Code, where it'll import the same classes/functions again, with a prefix
-
F-1 over 4 yearsAh I see, have you come across a discussion about the issue? I couldn't see anything on github.
-
Sajib Acharya over 4 yearsI don't think this is fixed since I am still having this issue on Android Studio 3.5.