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

后端 未结 5 899
挽巷
挽巷 2021-01-03 23:46

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

相关标签:
5条回答
  • 2021-01-04 00:18

    Flutter currently doesn't provide such a feature.
    There might be 3rd-party packages that do that. The only one I know is den (https://pub.dartlang.org/packages/den), but this one is not maintained since quite some time and can't be used with recent Dart or Flutter versions.

    What might help is to at least get a list of dependencies where newer versions are available.

    Upvote https://github.com/flutter/flutter/issues/12627 for that.

    In the meantime the workaround mentioned in https://github.com/flutter/flutter/issues/12627#issuecomment-400037072 can be used

    Set FLUTTER_ROOT to your Flutter install directory and run pub upgrade. (this requires the Dart SDK to be installed in addition to the Flutter SDK)

    $ export FLUTTER_ROOT="/Users/my_user/flutter"
    
    $ pub upgrade
    Resolving dependencies... (16.2s)
    ! analyzer 0.33.0 (overridden) (0.34.2 available)
      args 1.5.1
      async 2.0.8
      boolean_selector 1.0.4
    ! build 1.1.0 (overridden)
      built_collection 4.1.0
    ! built_redux 7.5.2 (overridden)
      built_value 6.2.0
      bwu_grinder_tasks 0.2.0-dev.0
      charcode 1.1.2
      cli_util 0.1.3+2
      collection 1.14.11
      contacts_service 0.0.9 (0.1.0 available)
    > convert 2.1.1 (was 2.0.2)
      crypto 2.0.6
      csslib 0.14.6
      dart_style 1.2.2
      device_info 0.2.1 (0.3.0 available)
    > file 5.0.7 (was 5.0.6)
    > firebase_analytics 1.1.0 (was 1.0.6)
    ...
    
    0 讨论(0)
  • 2021-01-04 00:27

    There a quick and dirty solution that just reads the pubspec.yaml file and then checks the latest version by web-scraping.

    https://gist.github.com/spidgorny/ed475cbbe303e1c09c0f6c9f9f57dcad

    Example:

    cupertino_icons: 0.1.2
    location: 2.3.5
    flutter_local_notifications: 0.8.4
    http: 0.12.0+1
     => 0.12.0+2
    haversine: 1.0.2
    flutter_map: 0.1.4
     => 0.7.3
    map_native: 0.0.11
    url_launcher: 5.1.4
    flutter_html_view: 0.5.12
    flutter_html: 0.8.2
    background_fetch: 0.2.0
     => 0.3.2
    package_info: 0.4.0+2
     => 0.4.0+6
    liquid_pull_to_refresh: 1.1.1
    provider: 3.0.0
     => 3.1.0
    yaml: any
    google_maps_flutter: 0.5.21+7
    
    0 讨论(0)
  • 2021-01-04 00:31

    Use 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.

    The pub outdated command was introduced in Dart 2.8.

    Outdated is one of the commands of the pub tool

    flutter pub outdated 
    

    Output columns

    The output of pub outdated has four columns of version information for each out-of-date dependency. Here is the part of the example output that shows the four version columns: Current, Upgradable, Resolvable, and Latest.

    Current The version used in your package, as recorded in pubspec.lock. If the package isn’t in pubspec.lock, the value is -.

    Upgradable The latest version allowed by your pubspec.yaml file. This is the version that pub upgrade resolves to. The value is - if the value in the Current column is -.

    Resolvable The latest version that can be resolved, when combined with all other dependencies. This version corresponds to what pub upgrade gives you if all version constraints in pubspec.yaml are unbounded. A value of - means that the package won’t be needed.

    Latest The latest version of the package available, excluding prereleases unless you use the option --prereleases.

    0 讨论(0)
  • 2021-01-04 00:37

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

    $ 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.
    
    0 讨论(0)
  • 2021-01-04 00:37

    You can use flutter packages upgrade, Flutter will verify new release versions with constraints notification if there is.

    Checkout the documentation about it here: https://flutter.io/docs/development/tools/sdk/upgrading

    Warning: (taken from the above link)

    Don’t use the pub get or pub upgrade commands to manage dependencies for Flutter apps. Instead, use flutter packages get or flutter packages upgrade. If you want to use pub manually, you can run it directly by setting the FLUTTER_ROOT environment variable.

    0 讨论(0)
提交回复
热议问题