$ pub update [PACKAGE]
Without any additional arguments,
pub update installs the latest versions of
all the dependencies listed in the
pubspec.yaml file in the
current working directory, as well as their transitive
dependencies, to the
directory located next to the pubspec. For example:
$ pub update Dependencies updated!
pub update updates dependency versions, it writes a
lockfile to ensure that future
installs will use the same versions of those dependencies.
Application packages should check in the lockfile to source control; this
ensures the application will use the exact same versions of all dependencies for
all developers and when deployed to production. Library packages should not
check in the lockfile, though, since they’re expected to work with a range of
If a lockfile already exists,
pub update will ignore it and generate a new one
from scratch using the latest versions of all dependencies. This is the primary
pub update and
pub install, which always tries to install
the dependency versions specified in the existing lockfile.
Updating specific dependencies
It’s possible to tell
pub update to update specific dependencies to the latest
version while leaving the rest of the dependencies alone as much as possible.
$ pub update unittest args Dependencies updated!
Updating a dependency updates its transitive dependencies to their latest versions as well. Usually, no other dependencies are updated; they stay at the versions that are locked in the lockfile. However, if the requested updates cause incompatibilities with these locked versions, they will be selectively unlocked until a compatible set of versions is found.
Installing a new dependency
If a dependency is added to the pubspec before
pub update is run, it will
install the new dependency and any of its transitive dependencies to the
packages directory. This is the same behavior as
Uninstalling a dependency
If a dependency is removed from the pubspec before
pub update is run, it
will remove the dependency from the
packages directory, thus making it
unavailable for importing. Any transitive dependencies of the removed dependency
will also be removed, as long as no remaining immediate dependencies also depend
on them. This is the same behavior as