A useful collection of custom lints for Flutter & Dart projects. Uses the new analysis_server_plugin system for direct integration with dart analyze and IDEs.
Browse all rules on the documentation site
Getting started
Requires Dart 3.11+ (Flutter 3.41+)
Add many_lints to the top-level plugins section in your analysis_options.yaml file (NOT under analyzer:):
plugins:
many_lints: ^0.9.0
That's it — the analysis server will automatically download and resolve the plugin from pub.dev. There is no need to add it to your pubspec.yaml.
Important: After any change to the
pluginssection, you must restart the Dart Analysis Server.
For local development setup, see CONTRIBUTING.md.
Configuring diagnostics
All rules are registered as warnings and enabled by default. You can enable or disable individual rules under the diagnostics key:
plugins:
many_lints:
version: ^0.9.0
diagnostics:
prefer_center_over_align: true
use_bloc_suffix: false
Excluding paths per rule
diagnostics: turns a rule on or off everywhere. To keep a rule on but skip certain paths, write a rules: block — in either of these two places, whichever you prefer:
Option A — in your existing analysis_options.yaml, under a top-level many_lints: key (note: top-level, a sibling of plugins:, not nested inside it):
# analysis_options.yaml
plugins:
many_lints: ^0.9.0
many_lints:
rules:
avoid_only_rethrow:
exclude:
- test/**
- "**/*.g.dart"
Option B — in a separate many_lints.yaml next to your pubspec.yaml:
# many_lints.yaml
rules:
avoid_only_rethrow:
exclude:
- test/**
- "**/*.g.dart"
Both are fully equivalent — the rules: block is identical, it just sits one level deeper in Option A. Use Option A to keep everything in one file, or Option B to keep lint config separate.
If you create both, many_lints.yaml wins outright and the analysis_options.yaml section is ignored — they are not merged.
Every rule supports exclude. Each exclude sits under one rule and affects only that rule — to skip a path for several rules, give each of them its own exclude.
Patterns are globs matched against the path relative to the package root, using the same semantics as the analyzer's own analyzer: exclude:. A plain path is a valid pattern too, and the list can hold as many entries as you need:
rules:
avoid_only_rethrow:
exclude:
- lib/legacy/parser.dart # one specific file
- lib/generated/** # a whole directory tree
- "**/*.g.dart" # every generated file
The
rules:block cannot live insideplugins: many_lints:— the analyzer only accepts enable/disable and severity there, and reports any other key as an unsupported option.
See Configuration for details.
Available Lints
133 lints with 92 quick fixes, all enabled by default as warnings. Each rule links to its full documentation with examples and fix details.
| Category | Rules | Description |
|---|---|---|
| Class Naming | 3 | Class and type naming conventions |
| Bloc / Riverpod | 10 | BLoC and Riverpod state management patterns |
| Riverpod State | 9 | Riverpod-specific state rules |
| Async Safety | 4 | Async/await and state mutation safety |
| Widget Best Practices | 18 | General widget best practices |
| Widget Replacement | 13 | Simpler widget alternatives |
| State Management | 8 | StatefulWidget and state patterns |
| Control Flow | 15 | Control flow statements and patterns |
| Collection & Type | 18 | Collection and type-related checks |
| Pattern Matching | 6 | Dart pattern matching best practices |
| Type Annotations | 5 | Type annotation conventions |
| Code Organization | 3 | Code structure and organization |
| Shorthand Patterns | 4 | Dot shorthand syntax patterns |
| Hook Rules | 4 | Flutter Hooks conventions |
| Testing Rules | 3 | Testing best practices and matchers |
| Resource Management | 3 | Resource cleanup and disposal |
| Code Quality | 7 | General code quality improvements |
Available Assists
- Convert to collection-for: Converts
.map().toList()or.map().toSet()to collection-for syntax.
Suppressing Diagnostics
To suppress a specific lint, use comments:
// ignore: many_lints/prefer_center_over_align
const Align(...);
// ignore_for_file: many_lints/use_bloc_suffix
The many_lints/ prefix is required. Unlike SDK lints, a plugin diagnostic is only silenced when the rule name is prefixed with the plugin name, so a bare // ignore: prefer_center_over_align has no effect. The prefix is the key used under plugins: in analysis_options.yaml.
Suppressing by type is also possible via // ignore: type=lint (the type= form is required, and it silences every lint on that line, SDK ones included).
Example
See the example/ directory for a Flutter project that demonstrates every lint rule in action. Each file corresponds to a single rule and contains code that triggers the lint.
Libraries
- main
- Re-exports
many_lints.dartfor analysis_server_plugin discovery. - many_lints
- Many Lints - A collection of useful lint rules for Dart and Flutter.
