Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Quick Constructor for Dart not working

I created this Dart Class in Visual Studio Code:

class User {
  String userId;
  String info;
}

Ctrl + . not opening the quick fix menu for a quick constructor.

enter image description here

Any suggestions on how to show all of the quick-fix options? like this -

enter image description here

like image 380
Omri Avatar asked Nov 06 '19 09:11

Omri


3 Answers

Add this extension on visual studio code Dart Data Class Generator. Execute on vscode ctrl + p and paste ext install BendixMa.dart-data-class-generator

installing "ext install BendixMa.dart-data-class-generator" execute "ctrl + ."

like image 137
Andy Luis Avatar answered Nov 10 '22 22:11

Andy Luis


That feature does not derive from the official Dart library extension, You should install this extension from Visual studio marketplace : from this link

if installed then try Ctrl + . within class and select Generate constructor.

you can follow below numbers to quick fix the

  1. Create a class with properties.
  2. Place your cursor on the first line of the class, the constructor or a field.
  3. Hit CTRL + . to open the quick fix dialog.
  4. Choose one of the available options.
  5. If extension won't work, then you may restart the VS Code.
like image 24
Dhiren Avatar answered Nov 11 '22 00:11

Dhiren


I have the same problem; The extension is installed but I still only have 'Convert class to a mixin'.

Edit: I restarted VSCode and the extension started to work. You may also need to clear workspace cache.

like image 21
jared chong Avatar answered Nov 10 '22 23:11

jared chong