Visual Studio Code adding 'prefix0' in Flutter

1,138

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.

Share:
1,138
Pyth0nGh057
Author by

Pyth0nGh057

Updated on December 13, 2022

Comments

  • Pyth0nGh057
    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
      F-1 over 4 years
      When I came across this issue it was because I had classes with the same name. It does this to avoid conflicts
    • Pyth0nGh057
      Pyth0nGh057 over 4 years
      Oh yes thanks ! I had the same import twice.
    • F-1
      F-1 over 4 years
      Great since that was the problem I've posted it as an answer
  • Rémi Rousselet
    Rémi Rousselet over 4 years
    That'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
    F-1 over 4 years
    Ah I see, have you come across a discussion about the issue? I couldn't see anything on github.
  • Sajib Acharya
    Sajib Acharya over 4 years
    I don't think this is fixed since I am still having this issue on Android Studio 3.5.