My Flutter project has a dependency flutter_dotenv
at version ^2.0.1
and I want to automatically upgrade to the new version ^2.0.2
.
I am running the following command to upgrade it:
flutter pub upgrade
Reference: Upgrading packages only
To update to the latest compatible versions of all the dependencies listed in the pubspec.yaml file, use the upgrade command:
flutter pub upgrade
However nothing seems to happen. pubspec.yaml
does not change, and the console output does not mention of a new version (which would be enough).
My pubspec.yaml
looks like this:
environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter flutter_dotenv: ^2.0.1 cupertino_icons: ^0.1.2 dev_dependencies: flutter_test: sdk: flutter flutter: uses-material-design: true
You can tell dart pub upgrade to upgrade specific dependencies to the latest version while leaving the rest of the dependencies alone as much as possible. For example: $ dart pub upgrade test args Dependencies upgraded! Upgrading a dependency upgrades its transitive dependencies to their latest versions as well.
Upgrading packages yaml file, or you want to update only the packages that your app depends upon (instead of both the packages and Flutter itself), then use one of the flutter pub commands. To identify out-of-date package dependencies and get advice on how to update them, use the outdated command.
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!
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With