Home > Back-end >  How to add multiple packages to pubspec.yaml from command line?
How to add multiple packages to pubspec.yaml from command line?

Time:01-26

I can add a package to my pubspec.yaml file from command line using:

dart pub add foo

But how to add multiple packages?

dart pub add foo, bar // Doesn't work

CodePudding user response:

Right now (Dart 2.15.1), the Dart pub tool does not support adding multiple package dependencies in one command. You therefore need to run pub add for each package you want to add as dependency for your project.

A pull request for pub have recently being merged which adds support for adding multiple dependencies in one operation.

You can find the issue here: https://github.com/dart-lang/pub/issues/3273

And pull request here: https://github.com/dart-lang/pub/pull/3283

Since this has happen rather recent, my own personal guess is, that this change is not going to be part of Dart 2.16 but rather Dart 2.17, since 2.16 has been closed for further development for some time to make it ready for release in the near future.

CodePudding user response:

////you can follow these steps to add plugin using terminal
    
    You can manage packages with flutter pub command.you can
    
   1. flutter pub add - 
    adds packages to your project's pubspec.yaml and downloads them. 
    So you don't have to run flutter pub get.
    
   2. flutter pub add <package>
    Add a package to your project's dependencies.  
    
  3. flutter pub add --dev <package>
    Similarly adds package to dev_dependencies.

  4. flutter pub remove <package>  
    Removes the package from your project's dependencies.
        
    Documentation: https://dart.dev/tools/pub/cmd

or you can use get_cli package hope these 2 solutions work for you.

  •  Tags:  
  • Related