Contents

dart pub outdated

Outdated is one of the commands of the pub tool.

$ dart pub outdated [options]

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.

Overview

Here’s how you can use dart pub outdated to help you update the dependencies of a package that you own (whether it’s an app or library package):

  1. If your package doesn’t have a pubspec.lock file checked into source control, run dart pub get in the top directory of the package — the directory that contains your package’s pubspec.yaml file.
  2. Run dart pub outdated to identify which package dependencies are out-of-date. Note the affected packages, so that later you can test the behavior of code that uses them.
  3. Follow the recommendations of dart pub outdated for updating the packages. Some updates might require only running dart pub upgrade. Others might require updating pubspec.yaml before running dart pub upgrade.
  4. Run dart pub outdated to confirm that you’re using the latest compatible package versions.
  5. Test your package to confirm that it still works as expected.

You might still have out-of-date dependencies due to transitive dependencies. If you want to determine the cause, try running dart pub deps and searching the output for the name of each out-of-date package.

Example

Here’s an example of running dart pub outdated on an example that has several out-of-date dependencies. Three of the dependencies (args, http, and path) are direct, and one is transitive (meta). As the following example shows, dart pub outdated colorizes the output by default when you run it on the command line.

$ dart pub outdated

Dependencies  Current    Upgradable  Resolvable  Latest  
args          1.4.4      1.6.0       1.6.0       1.6.0   
http          0.11.3+17  0.11.3+17   0.12.1      0.12.1  
path          1.6.2      1.6.2       1.6.2       1.7.0   

dev_dependencies: all up-to-date

transitive dependencies
meta          1.1.6      1.1.6       1.1.6       1.1.8   

transitive dev_dependencies: all up-to-date

1 upgradable dependency is locked (in pubspec.lock) to an older version.
To update it, use `dart pub upgrade`.

1 dependency is constrained to a version that is older than a resolvable version.
To update it, edit pubspec.yaml.

The Resolvable column shows which versions you can upgrade to for each out-of-date dependency. You can get more information by looking for the leftmost column with a non-red value. For example, args is upgradable to 1.6.0, and http is resolvable to 0.12.1. The path and meta packages aren’t the latest versions, but are the most current resolvable versions, considering all the other dependencies.

To fix the first dependency (args), which is listed as upgradable, you just need to run dart pub upgrade:

$ dart pub upgrade
Resolving dependencies... 
> args 1.6.0 (was 1.4.4)
  ...
Changed 1 dependency!

To fix the second dependency (http), which is listed as resolvable, you can change the pubspec’s http entry to use the version in the Resolvable column (or a compatible higher version). In caret syntax, that’s ^0.12.1. Here’s the diff for pubspec.yaml:

-  http: ^0.11.0
+  http: ^0.12.1

After editing pubspec.yaml, you run dart pub upgrade to update the pubspec.lock file. You can then run dart pub outdated to confirm that you’ve made all necessary changes. In this example, the path and meta packages are still out-of-date, due to reasons that this package doesn’t control:

$ dart pub upgrade
...
$ dart pub outdated
Dependencies  Current  Upgradable  Resolvable  Latest  
path          1.6.2    1.6.2       1.6.2       1.7.0   

dev_dependencies: all up-to-date

transitive dependencies
meta          1.1.6    1.1.6       1.1.6       1.1.8   

transitive dev_dependencies: all up-to-date

Dependencies are all on the latest resolvable versions.
Newer versions, while available, are not mutually compatible.

To see why these packages are out-of-date, you can run dart pub deps and look for dependencies on these packages:

$ dart pub deps -s list
...
dependencies:
...
- terminal_tools 0.1.0
  - path 1.6.2
  - meta 1.1.6
...

As the preceding output shows, this package depends on the terminal_tools package, which depends on old versions of path and meta. Once the terminal_tools package is updated, it should be possible to update this package.

Output columns

The output of dart 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.

Dependencies  Current    Upgradable  Resolvable  Latest  
args          1.4.4      1.6.0       1.6.0       1.6.0   
http          0.11.3+17  0.11.3+17   0.12.1      0.12.1  
path          1.6.2      1.6.2       1.6.2       1.7.0   

dev_dependencies: all up-to-date

transitive dependencies
meta          1.1.6      1.1.6       1.1.6       1.1.8
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 dart 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 dart 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.

For example, say your app depends on the foo and bar packages, but the latest version of bar allows only older major versions of foo. The result is that the latest resolvable version of foo is different from the latest version of foo.

When you edit the pubspec.yaml file, you generally update the dependencies and dev_dependencies sections so that each package uses the versions in the Resolvable column.

Options

For options that apply to all pub commands, see Global options.

--[no-]color

Adds color to the output for emphasis (--color). The default depends on whether you’re using this command at a terminal. At a terminal, --color is the default, otherwise, --no-color is the default. Use --no-color to disable color in all environments.

--[no-]dependency-overrides

By default, accounts for dependency_overrides when resolving package constraints (--dependency-overrides). To not consider overrides, use --no-dependency_overrides.

--[no-]dev-dependencies

By default, accounts for dev dependencies when resolving package constraints (--dev-dependencies). To not consider dev dependencies, use --no-dev-dependencies.

--json

Generates output in JSON format.

--[no-]prereleases

By default, includes prereleases when determining the last package versions (--prereleases). To not consider preleases, use --no-prereleases.

--[no-]transitive

By default, doesn’t include transitive dependencies as part of the output (--no-transitive). To include transitive dependencies, use --transitive.

--[no-]up-to-date

By default, doesn’t include dependencies that are at the latest version (--no-up-to-date). To include up-to-date dependencies, use --up-to-date.