VSCode replacing _$ instead of autocomplete

193

I tried to replicate the problem and I concluded this could be an issue related to the current VS Code Intellisense.

I tried calling some functions with an underscore _ or a dollar $ in the name. The Intellisense always suggest the complete function name, but when I confirm, it truncate the name at the $ sign.

I did replicate in the following way:

  1. Define a file .dart with a class
  2. Define a function within the class, named with a dollar sign somewhere (ex. void test$function(){} )
  3. Call that function from somewhere. The Intellisense will provide a suggestion, but if you accept, the result will be truncated at the dollar sign.
class Test {
  Test(this.name, this.email);

  String name;
  String email;

  String test$function() =>'test';
  
}

Trying to call test$function() with autocomplete result in a test().

The problem does not occur in Android Studio.

It doesn't seems to be related or caused by json_serializable.

The underscore doesn't seems to be related to the problem.

I can't provide a fix for this but I did open an issue in VS Code Github here.

EDIT:

It was actually a bug from the Dart sdk. It will be fixed in Dart v2.14

You can read here

Share:
193
Sergey Shustikov
Author by

Sergey Shustikov

Android developer

Updated on December 30, 2022

Comments

  • Sergey Shustikov
    Sergey Shustikov over 1 year

    I'm using VSCode for coding with Flutter. Also, I'm using generators for building Json classes automatically with json_serializable library.

    But when I'm typing _$ sign to make autocomplete

    enter image description here

    It replaces to

    enter image description here

    when I hit Enter or Tab

    How to fix this?