Reputation: 5777
How to set to use the latest version of a package in pubspec.yaml for Dart projects?
Can I do something like:
dev_dependencies:
build_runner: latest
build_web_compilers: latest
in pubspec.yaml
Upvotes: 7
Views: 5990
Reputation: 90015
See the version constraints documentation for how package version constraints can be specified.
There is no direct way to use the "latest" version of a package, but that is not a good idea since a later version of a package might not be backward compatible.
You instead can do:
some_package: ">= 1.2.3 < 2.0.0"
since packages should use semantic versioning and change the major version number to indicate backward-incompatible changes.
You also can use:
some_package: "^1.2.3"
to indicate package versions expected to be compatible with 1.2.3 (but this is based on semantic versioning conventions and is equivalent to ">= 1.2.3 < 2.0.0"
.
Finally, if you really don't care about package versions at all, you could specify an unrealistically high maximum version:
some_package: ">= 1.2.3 < 9999999.0.0"
or disable version constraints entirely:
some_package: any
Upvotes: 7