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.
Asked
Active
Viewed 1.3k times
2 Answers
23
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).

Alexandre Ardhuin
- 71,959
- 15
- 151
- 132
-
Anyway to make it add the import using package: instead of relative paths ? – Cristiano Apr 12 '19 at 12:03
-
very useful. Always used to get problem with this. Cmd and . solves the problem – Sreehari Mar 28 '20 at 05:57
1
Alternatively, you can use the following Vscode extensions to auto import dependencies:
https://marketplace.visualstudio.com/items?itemName=davidwoo.flutter-auto-import

FVVID
- 155
- 1
- 9