How to automatically upgrade Flutter dependencies

Above method works but you can use this command:

flutter pub upgrade --major-versions

It will update all your dependencies.

Also check "How to correctly add dependencies to avoid "Version solving failed" error

Refer to this: https://stackoverflow.com/a/67517680/13500457

I hope it clears everything, happy coding!


Running pub won't ever change pubspec.yaml. However, it might solve to a version different from the 'base' version specified - the leading caret allows pub to solve to:

the range of all versions guaranteed to be backwards compatible with the specified version

Check in the pubspec.lock file and you'll probaby see that pub has already solved to version: "2.0.2"


Flutter automatically upgrades non-breaking changes based on semantic versioning. You wouldn't want breaking changes to be automatic. The updates are reflected in pubspec.lock, but not pubspec.yaml.

There are a couple IDE plugins that can help you to upgrade packages more easily than looking them up one by one on pub.dev.

Android Studio

Flutter Pub Version Checker

This plugin highlights any dependencies in pubspec.yaml you have that are out of date so that you can choose to update them if you want to.

Visual Studio Code

Pubspec Assist

This plugin makes it super simple to add or update a dependency without going to pub.dev, but you still have to check them one at a time.