Rule Catalog
Falcon includes 58+ lint rules organized into 6 categories. These rules help you catch bugs, enforce best practices, and improve code quality across your Flutter and Dart projects.
Common Rules
31 rules covering general Dart best practices, type safety, and code style.
| Rule | Severity | Description |
|---|---|---|
avoid-dynamic | Error | Discourages use of the dynamic type; prefer explicit types for better type safety. |
avoid-empty-catch | Error | Flags empty catch blocks that silently swallow exceptions; require proper error handling. |
avoid-global-state | Error | Warns against mutable global variables that make code harder to test and reason about. |
avoid-hardcoded-credentials | Error | Detects hardcoded passwords, API keys, or secrets in source code. |
avoid-throw-in-catch | Error | Flags re-throwing errors in catch blocks without proper wrapping or context. |
avoid-unawaited-futures | Error | Detects Future calls that are not awaited, which can cause unhandled errors. |
avoid-late-keyword | Warning | Suggests alternatives to late when initialization can be guaranteed. |
avoid-long-functions | Warning | Discourages functions that exceed a configurable length threshold. |
avoid-long-parameter-list | Warning | Flags functions with too many parameters; suggests using objects or records. |
avoid-nested-conditionals | Warning | Encourages early returns to reduce nesting depth. |
avoid-non-ascii-symbols | Warning | Discourages non-ASCII characters in identifiers for portability. |
avoid-print-in-production | Warning | Flags print statements that should be removed or replaced with logging. |
avoid-unnecessary-type-assertions | Warning | Detects redundant ! or type assertions when type is already known. |
avoid-unnecessary-type-casts | Warning | Flags unnecessary as casts that add no value. |
avoid-unused-parameters | Warning | Detects function parameters that are never used. |
avoid-cascade-after-if-null | Warning | Warns about cascades after ?? which may not behave as expected. |
avoid-collection-methods-unrelated-types | Warning | Flags collection methods used with incompatible element types. |
avoid-double-negation | Warning | Discourages !! or redundant negation patterns. |
avoid-duplicate-exports | Warning | Detects duplicate export directives in library files. |
avoid-missing-enum-constant-in-map | Warning | Ensures all enum values are handled in switch/map expressions. |
avoid-top-level-members-in-tests | Warning | Discourages top-level variables in test files that can cause test pollution. |
prefer-correct-identifier-length | Warning | Enforces reasonable identifier length for readability. |
prefer-match-file-name | Warning | Ensures library/part names match the file name. |
prefer-named-boolean-parameters | Warning | Suggests named parameters for boolean arguments to improve clarity. |
prefer-specific-catch-type | Warning | Encourages catching specific exception types instead of Object. |
no-magic-numbers | Warning | Flags unexplained numeric literals; suggests named constants. |
binary-expression-operand-order | Info | Enforces consistent operand order in binary expressions. |
double-literal-format | Info | Enforces consistent formatting of double literals. |
newline-before-return | Info | Requires a blank line before return statements. |
prefer-first-last | Info | Suggests first/last over [0]/[length-1] for iterables. |
prefer-trailing-comma | Info | Encourages trailing commas in multi-line collections for cleaner diffs. |
Flutter Rules
11 rules specific to Flutter widget lifecycle, performance, and accessibility.
| Rule | Severity | Description |
|---|---|---|
ensure-dispose-lifecycle | Error | Ensures controllers and subscriptions are disposed in dispose(). |
ensure-stream-subscription-cancel | Error | Requires StreamSubscription to be cancelled to prevent memory leaks. |
avoid-unnecessary-setstate | Error | Flags unnecessary setState calls that don't change state. |
avoid-returning-widgets | Warning | Discourages returning widgets from non-build methods; prefer extracting widgets. |
avoid-excessive-widget-nesting | Warning | Flags deeply nested widget trees that hurt readability and performance. |
prefer-const-constructors | Warning | Suggests const constructors when widgets don't depend on runtime values. |
prefer-extracting-callbacks | Warning | Encourages extracting inline callbacks to named methods for clarity. |
ensure-semantics-label | Warning | Requires semantic labels for interactive widgets for accessibility. |
ensure-image-semantics | Warning | Ensures images have semantic labels for screen readers. |
avoid-expanded-as-spacer | Info | Suggests SizedBox or Spacer instead of Expanded for spacing. |
ensure-touch-target-size | Info | Ensures touch targets meet minimum size (e.g., 48x48 logical pixels). |
Code Examples
avoid-empty-catch
Empty catch blocks silently swallow exceptions, making debugging difficult. Always handle or rethrow errors.
Bad
try {
await fetchData();
} catch (e) {
// empty — error is silently ignored
}
Good
try {
await fetchData();
} catch (e, stackTrace) {
logError(e, stackTrace);
rethrow;
}
ensure-dispose-lifecycle
Controllers and subscriptions must be disposed to prevent memory leaks. Override dispose() and clean up resources.
Bad
class MyWidget extends StatefulWidget {
final TextEditingController controller =
TextEditingController();
// Missing dispose — controller leaks
}
Good
class MyWidget extends StatefulWidget {
final TextEditingController controller =
TextEditingController();
@override
void dispose() {
controller.dispose();
super.dispose();
}
}
avoid-unawaited-futures
Futures must be awaited to handle errors and ensure proper execution order. Unawaited futures can cause unhandled exceptions.
Bad
void saveData() {
writeToFile(data); // Future not awaited — errors lost
}
Good
Future<void> saveData() async {
await writeToFile(data);
}
BLoC Rules
5 rules for projects using the BLoC pattern for state management.
| Rule | Severity | Description |
|---|---|---|
bloc-avoid-public-members | Warning | Encourages encapsulating BLoC internals; avoid exposing implementation details. |
bloc-avoid-context-read | Warning | Discourages context.read in build methods; prefer BlocBuilder/BlocListener. |
bloc-close-subscription | Error | Ensures Bloc is closed when no longer needed to prevent leaks. |
bloc-avoid-emit-after-close | Error | Flags emit calls after the bloc has been closed. |
bloc-prefer-cubit | Info | Suggests Cubit over full Bloc when events are not needed. |
Provider / Riverpod Rules
5 rules for projects using Provider or Riverpod for dependency injection and state management.
| Rule | Severity | Description |
|---|---|---|
provider-dispose | Error | Ensures Provider resources are properly disposed when no longer needed. |
provider-avoid-context-read-in-build | Warning | Discourages context.read/watch in build; use Consumer or context extensions. |
riverpod-avoid-dispose-in-build | Error | Flags ref.dispose or similar calls during build phase. |
riverpod-prefer-ref | Info | Suggests using ref over context when both are available in providers. |
riverpod-keep-alive | Info | Recommends autoDispose or keepAlive based on provider lifecycle needs. |
Equatable Rules
3 rules for projects using Equatable for value equality.
| Rule | Severity | Description |
|---|---|---|
equatable-props-complete | Error | Ensures all relevant properties are listed in the props getter. |
equatable-avoid-mutable-props | Warning | Discourages mutable types in Equatable props; use immutable copies. |
equatable-prefer-const | Info | Suggests const constructors for Equatable classes when possible. |
Presets
Presets bundle related rules for quick configuration. Choose a preset that matches your project's dependencies.
| Preset | Rule Count | Description |
|---|---|---|
recommended | 42 | Default preset with common and Flutter rules; suitable for most projects. |
strict | 58 | All rules enabled; maximum enforcement for high-compliance projects. |
minimal | 12 | Only critical error-level rules; minimal friction for new projects. |
bloc | 47 | Recommended + BLoC rules; for projects using flutter_bloc. |
riverpod | 47 | Recommended + Riverpod rules; for projects using flutter_riverpod. |
provider | 46 | Recommended + Provider rules; for projects using provider. |