Skip to content

Commit

Permalink
Update per review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Tony Sansone committed Jan 12, 2024
1 parent 4b27946 commit d760144
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/tools/pub/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit d760144

Please sign in to comment.