Skip to content

Files

Latest commit

 

History

History
42 lines (28 loc) · 881 Bytes

depend_on_referenced_packages.md

File metadata and controls

42 lines (28 loc) · 881 Bytes

Pattern: Missing dependency on referenced package

Issue: -

Description

DO Depend on referenced packages.

When importing a package, add a dependency on it to your pubspec.

Depending explicitly on packages that you reference ensures they will always exist and allows you to put a dependency constraint on them to guard you against breaking changes.

Whether this should be a regular dependency or dev_dependency depends on if it is referenced from a public file (one under either lib or bin), or some other private file.

Example of incorrect code:

import 'package:a/a.dart';
dependencies:

Example of correct code:

import 'package:a/a.dart';
dependencies:
 a: ^1.0.0

Further Reading