pub downgradeSend feedback
Downgrade is one of the commands of the pub tool. Learn more about pub.
$ pub downgrade [args] [dependencies]
Without any additional arguments,
pub downgrade gets the lowest versions of
all the dependencies listed in the
in the current working directory, as well as their transitive
dependencies, to the
$ pub downgrade Resolving dependencies... (1.2s) + barback 0.13.0 + collection 0.9.1 + path 1.2.0 + source_maps 0.9.0 + source_span 1.0.0 + stack_trace 0.9.1 Changed 6 dependencies!
pub downgrade command creates a lockfile. If one already exists,
pub ignores that file and generates a new one from scratch, using the lowest
versions of all dependencies.
pub downgrade command supports the same command-line arguments
pub get command.
Downgrading specific dependencies
It’s possible to tell
pub downgrade to downgrade specific dependencies to the
lowest version while leaving the rest of the dependencies alone as much as
possible. For example:
$ pub downgrade test Resolving dependencies... barback 0.15.2+2 bot 0.27.0+2 browser 0.10.0+2 chrome 0.6.5 collection 1.1.0 path 1.3.0 pool 1.0.1 source_span 1.0.2 < stack_trace 0.9.2 (was 1.1.1) stagexl 0.10.2 < test 0.10.0 (was 0.11.4) These packages are no longer being depended on: - matcher 0.11.3 Changed 3 dependencies!
If you are downgrading a specific dependency, pub tries to find the highest versions of any transitive dependencies that fit the new dependency constraints. Any transitive dependencies are usually also downgraded as a result.
Getting a new dependency
If a dependency is added to the pubspec before
pub downgrade is run,
it gets the new dependency and any of its transitive dependencies and
places them in the
.packages file. This
is the same behavior as
Removing a dependency
If a dependency is removed from the pubspec before
pub downgrade is
run, it removes the dependency from the
thus making the dependency unavailable for
importing. Any transitive dependencies of the removed dependency are
also removed, as long as no remaining immediate dependencies also
depend on them. This is the same behavior as
Downgrading while offline
If you don’t have network access, you can still run
pub downgrade. Since pub
downloads packages to a central cache shared by all packages on your system, it
can often find previously-downloaded packages there without needing to hit the
However, by default, pub always tries to go online when you downgrade if you
have any hosted dependencies so that it can see if newer versions of them are
available. If you don’t want it to do that, pass the
--offline flag when
running pub. In this mode, it only looks in your local package cache and
tries to find a set of versions that work with your package from what’s already
For options that apply to all pub commands, see Global options.