depend_on_referenced_packages
Depend on referenced packages.
This rule is available as of Dart 2.14.
Rule sets: core, recommended, flutter
Details
#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.
BAD:
import 'package:a/a.dart';
dependencies:
GOOD:
import 'package:a/a.dart';
dependencies:
a: ^1.0.0
Usage
#To enable the depend_on_referenced_packages
rule,
add depend_on_referenced_packages
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- depend_on_referenced_packages
除非另有说明,文档之所提及适用于 Dart 3.5.3 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。