diff --git a/src/tools/pub/dependencies.md b/src/tools/pub/dependencies.md index 639bd677d1..f0fc065037 100644 --- a/src/tools/pub/dependencies.md +++ b/src/tools/pub/dependencies.md @@ -417,10 +417,12 @@ are ignored by all users of your package. ## Best practices Be proactive in managing your dependencies. -Ensure that your packages use the freshest versions possible. -Any stale dependencies could themselves depend on other stale packages. -These stale versions can have a negative impact on -the stability, performance, and quality of apps. +Ensure that your packages depend on the freshest versions of packages +when possible. +If your package depends on a stale package, +that stale package may depend on other stale packages in its dependency tree. +Stale versions of packages can have a negative impact on +the stability, performance, and quality of your app. The Dart team recommends the following best practices for package dependencies. @@ -439,16 +441,15 @@ To identify dependencies in your app or package that aren't on the latest stable versions, use [`dart pub outdated`][]. -### Use tight dev_dependencies +### Tighten version constraints for dev_dependencies -Dependencies can be loose, specifying dependency at the highest version digit -like `^2.0.0`, or tight, specifying dependency at the lowest version digit like -`^1.2.4`. +A dev dependency retrieves packages that you need only when developing. +These packages aren't needed in a finished app, like tests or examples. +Set the versions of package in [`dev_dependencies`][dev-dep] +to the exact version on which your package depends. -In your `pubspec.yaml` file, follow these recommendations. - -* Set regular `dependencies` loose to increase the chance of a version solver success. -* Set [`dev_dependencies`][dev-dep] tighter as they lack transitive concerns. +An example of how to set versions for dependencies would resemble the +following `pubspec.yaml` example. ```yaml dependencies: @@ -463,6 +464,9 @@ dev_dependencies: flutter_lints: ^3.0.1 ``` +This YAML sets the `dependencies` to the major version and the +`dev_dependencies` to a specific patch version. + [dev-dep]: /tools/pub/dependencies#dev-dependencies ### Test whenever you update package dependencies