I want to install latest Flutter packages in my android studio project.
In npm, npm install <package name> installs latest packages automatically and npm update updates all packages automatically.
Is there any way to do this in Flutter?
I want to install latest Flutter packages in my android studio project.
In npm, npm install <package name> installs latest packages automatically and npm update updates all packages automatically.
Is there any way to do this in Flutter?
Yes it is possible to update existing packages. Use the flutter command below:
flutter pub outdated
This was introduced in Dart 2.8:
As of Dart 2.8, you can use
pub outdated, a new tool for automatically determining which of your dependencies need to be updated to the latest and greatest versions.
Let's say you have these packages in your pubspec.yaml file
dependencies:
foo: ^1.0.0
bar: ^5.0.0
And at some point in future there is an update available for both of them, and you decide to run
flutter pub outdated
It would now list something like:
Dependencies Current Upgradable Resolvable Latest
foo 1.0.0 1.2.0 1.2.0 1.2.0
bar 5.0.0 5.3.0 6.0.0 6.0.0
You see there is no breaking change for foo, since it is still on 1.x.x, however, bar has got a breaking change, it has been updated from 5.x.x to 6.x.x. So what should you do now?
If you safely want to update the packages without breaking your code, run
flutter pub upgrade
This would now create pubspec.lock file with
packages:
foo:
version: "1.2.0"
bar:
version: "5.3.0"
If you want to update both of them to the latest version, you'll have to manually do it in pubspec.yaml file by specifying (foo won't need manual version):
dependencies:
bar: ^6.0.0
This would create pubspec.lock file with
packages:
foo:
version: "1.2.0"
bar:
version: "6.0.0"
With a release of Flutter 2.0 you can now upgrade flutter dependency packages automatically using these below command lines:
flutter pub outdated
flutter pub upgrade --major-versions
You can check version is out dated or not using flutter pub outdated command.
in output you will get all outdated versions.
Output:
Dependencies Current Upgradable Resolvable Latest
carousel_pro *0.0.13 *0.0.13 1.0.0 1.0.0
firebase_auth *0.15.4 *0.15.5+3 0.16.0 0.16.0
Here, current version show, which you are using and latest show which package version is available.
Note: You have to specify latest version in pubspec.yaml file and then you have to run.
flutter pub get