dart_code_quality 0.3.0
dart_code_quality: ^0.3.0 copied to clipboard
A collection of analyzer rules for Dart and Flutter development.
Dart Code Quality #
Dart code quality (DCQ) is a collection of analyzer rules designed to aid in Dart, and Flutter development. Additionally popular frameworks such as Riverpod have their own rules.
Rules are separated into distinct categories:
- Critical
- Correctness
- Maintainability
- Performance
- Style
Style rules are mostly recommended for ensuring homogeneity when working on a team. The rest can be used anywhere, and it's highly recommended to use the Critical rules.
Usage #
Add the plugin and include the recommended preset in your
analysis_options.yaml:
include: package:dart_code_quality/recommended.yaml
plugins:
dart_code_quality: ^0.3.0
Configuring rules #
Enable, disable, or configure individual rules via dart_code_quality: rules::
dart_code_quality:
rules:
# Disable a recommended rule
avoid-non-null-assertion: false
# Enable an opt-in rule
prefer-conditional-expressions: true
# Enable with options
avoid-long-files:
max-length: 200
Suppressing a diagnostic #
// ignore: avoid-dynamic
dynamic x = 1;
Rule Groups #
| Group | Description |
|---|---|
| Common | General Dart rules — correctness, async safety, null safety, dead code |
| Flutter | Widget lifecycle, state management, layout best practices |
| Riverpod | Provider patterns, ref usage, notifier correctness |
| Equatable | Props completeness, mixin usage |
| Easy Localization | Missing tr calls |
| Intl | Format patterns, intl name conventions |
| Fake Async | Async callbacks in fakeAsync |
See docs/rules.md for the full rule list.