0

How do I flutter packages to the pubspec.yaml file without going directly to the pubspec.yaml file.

I want to be able to add packages without leaving the current page I am working on.

I have seen this done in several tutorials and I want to know how it is done.

Anthony Aniobi
  • 238
  • 4
  • 15

1 Answers1

-1

There are two ways of doing auto import in vscode:

  1. Setting up Pubspec assist in VScode
  2. Using the terminal (this does not require any extension)

1. To setup in Pubspec Assist vscode use the instructions below:

  1. Install Pubspec assist extension in Vscode
  2. Then go to the command panel using the shortcut [Ctrl+Shift+P on Windows OR ⌘+Shift+P on Mac](without the '+')
  3. On the text field type - Pubspec Assist: add/update dependencies
  4. 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

Anthony Aniobi
  • 238
  • 4
  • 15