Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSCode Dart Import Shortcut

Does VSCode and/or a plugin offer a keyboard shortcut to automatically add an import in a Dart file? In IntelliJ and Android Studio this effect is easily achieved with Opt+Enter.

like image 765
SuperDeclarative Avatar asked Feb 07 '19 07:02

SuperDeclarative


People also ask

How do I import a Flutter package into VSCode?

Adding a package dependency to an app From the terminal: Run flutter pub get . From Android Studio/IntelliJ: Click Packages get in the action ribbon at the top of pubspec.yaml . From VS Code: Click Get Packages located in right side of the action ribbon at the top of pubspec.yaml .

Can we use Dart in VSCode?

With the Dart plugin, you can use Visual Studio Code (VS Code) to develop Dart apps. The Flutter site has details on how to set up and use VS Code for Flutter apps.


1 Answers

If you try to organize imports you can use Alt+Shift+O.

If you have a Type not recognised in the current file, you can use Ctrl+. (macOS: Cmd+.) to open Quick Fixes and select the imports you need (the searched import are dependent to your pubspec file).

See the key bindings of the Dart extension.

like image 198
Alexandre Ardhuin Avatar answered Sep 22 '22 23:09

Alexandre Ardhuin