简体   繁体   中英

How to update single package in pubspec.yaml file in Flutter

Let's say I'm having two packages in my pubspec.yaml file.

abc: any
xyz: any

Now, I only want to update abc package, how do I do that, is there any command like

flutter update abc

First, comment that the packaging line in the pubspec.yaml file and run flutter pub get after successfully get packages to uncomment that line (if you want to upgrade/downgrade to a specific version that mentioned version too) it will upgrade to the latest version.

In your case:

step 1:

// abc: any
   xyz: any
  • run flutter pub get

step 2:

  abd: any
  xyz: any

So now abc will upgrade to the latest version

To upgrade abc package and leaving others as it is, run:

dart pub upgrade abc

To upgrade all the packages, run:

dart pub upgrade

Run this command in the terminal

pub upgrade abc args

where abc is the package name you want to upgrade. Be sure you are in the project root directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM