Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find and version bump outdated packages in Flutter (across major versions)

Tags:

flutter

dart

Is there a way to list and update packages that have crossed a major version in pubspec.yaml? (like this method used in NPM)

E.g. when the pubspec.yaml file has this with built_value:

dependencies:   flutter:     sdk: flutter   built_value: ^5.0.0 

When built_value is updated to version ^6.2.0 is there a way to upgrade past the major version so the pubspec.yaml is updated to:

dependencies:   flutter:     sdk: flutter   built_value: ^6.2.0 

I know I can manually check each package for major versions, but it would be helpful if it was automatic.

like image 815
S.D. Avatar asked Jan 18 '19 06:01

S.D.


People also ask

How do you update outdated packages in flutter?

To update it, use `pub upgrade`. 4 dependencies are constrained to versions that are older than a resolvable version. To update these dependencies, edit pubspec. yaml.

What does Pub outdated do?

Outdated is one of the commands of the pub tool. Use dart pub outdated to identify out-of-date package dependencies and get advice on how to update them. Best practices for dependency management include using the most recent stable package versions, so you can get the latest bug fixes and improvements.

Where are all the flutter packages stored?

If you are running Windows as your OS, you can find the packages under the folder that you installed your Flutter SDK to when setting up Android Studio. In my case - using Windows 10 - the path is as follows, where C:\ is my primary harddrive and flutter\ the folder containing the Flutter SDK...


1 Answers

With the latest beta versions of Flutter (v1.17) there is now a pub command to check for, and update, outdated dependencies.

To check for outdated dependencies, run:

$ flutter pub outdated -h Analyze dependencies to find which ones can be upgraded. This runs the "pub" tool in a Flutter context.  Usage: flutter pub outdated [<arguments...>] -h, --help    Print this usage information.  Run "flutter help" to see global options. 

and this gives output like:

$ flutter pub outdated Dependencies                           Current              Upgradable           Resolvable           Latest path                                   *1.6.4               *1.6.4               *1.6.4               1.7.0 permission_handler                     *4.4.0+hotfix.4      *4.4.0+hotfix.4      5.0.0+hotfix.3       5.0.0+hotfix.3  dev_dependencies analyzer                               *0.36.4              *0.36.4              *0.36.4              0.39.7 build_runner                           *1.7.4               *1.7.4               *1.7.4               1.9.0  transitive dependencies asn1lib                                *0.5.15              *0.5.15              *0.5.15              0.6.4 permission_handler_platform_interface  *1.0.0               *1.0.0               2.0.0                2.0.0  transitive dev_dependencies build                                  *1.1.6               *1.1.6               *1.1.6               1.2.2 build_config                           *0.4.1+1             *0.4.1+1             *0.4.1+1             0.4.2 dart_style                             *1.2.9               *1.2.9               *1.2.9               1.3.6  1 upgradable dependency is locked (in pubspec.lock) to an older version. To update it, use `pub upgrade`.  4  dependencies are constrained to versions that are older than a resolvable version. To update these dependencies, edit pubspec.yaml. 

To update with compatible dependencies, run:

flutter pub upgrade 

or to update with potentially breaking changes, use

flutter pub upgrade --major-versions 
like image 173
SoftWyer Avatar answered Sep 23 '22 12:09

SoftWyer