There are two ways of doing auto import in vscode:
- Setting up Pubspec assist in VScode
- Using the terminal (this does not require any extension)
1. To setup in Pubspec Assist vscode use the instructions below:
- Install Pubspec assist extension in Vscode
- Then go to the command panel using the shortcut [Ctrl+Shift+P on Windows OR ⌘+Shift+P on Mac](without the '+')
- On the text field type - Pubspec Assist: add/update dependencies
- Enter the name of the package you want to find
Nb:
- You install multiple packages once by separating them with commas
eg: bloc, provider, http
- You only need to go through process 2 to 5 whenever you need to install a package again
hope this helps
2. To use Terminal
- Go to the terminal and type:
flutter pub add <package name>
eg: flutter pub add bloc
- To upgrade a package use:
flutter pub upgrade <package name><br>
eg. flutter pub upgrade bloc
this second method does not bring up a dialog but also does the same auto import
Have a nice day