Rules
148 rules across 5 groups, 140 recommended. 3 run across the whole project graph.
Correctness
18 rules · 18 recommendedCode that is outright wrong or will not behave as intended.
Disallow mutable global and static state.
Disallow mutable top-level variables.
Disallow relative imports that reach into a `lib/` directory.
Disallow functions and methods that return a `Widget`.
Disallow declared parameters that are never used.
Disallow importing web-only `dart:` libraries from Flutter code.
Require `super.dispose()` to be the last call in `dispose`.
Require `hashCode` and `==` to be overridden together.
Disallow importing another package's private `src/` files.
Require `createState` to do nothing but return a new `State` instance.
Require controllers owned by a `State` to be disposed.
Require `Expanded` and `Flexible` to sit directly inside a flex widget.
Require `fromEnvironment` to be evaluated in a const context.
Require `super.initState()` to be the first call in `initState`.
Disallow Flutter framework imports that the file does not use.
Disallow nullable return types on functions that never return null.
Require Riverpod once-providers to be created through `.once()`.
Disallow `RegExp` patterns that are structurally invalid.
Suspicious
22 rules · 22 recommendedPatterns that are probably a mistake or a latent bug.
Flags explicit `dynamic` type annotations.
Flags an `else` clause whose body is an empty statement (`else ;`).
Flags a call whose non-void return value is discarded.
Flags an `async` function literal passed where a synchronous callback is expected.
Flags calls to the top-level `print` function.
Flags `return null;` (and `=> null` bodies) in a function whose declared return type is `void` or `Future<void>`.
Flags a type parameter that shadows a type parameter of an enclosing declaration.
Flags a `throw` of a new object inside a `catch` block.
Flags an `is` check that can never succeed because the operand's type is unrelated to the tested type.
Flags `return`, `break`, or `continue` that escapes a `finally` block.
Flags empty `catch` blocks.
Flags stray empty statements (a lone `;`).
Flags a switch `case` whose value duplicates an earlier case in the same switch.
Flags empty blocks (`{}`).
Flags an argument passed more than once in the same invocation.
Flags an `if`/`else` or ternary whose two branches are identical.
Flags a comparison whose two operands are identical.
Flags references to a wildcard variable or parameter (a name made solely of underscores, such as `_` or `__`).
Flags a getter that unconditionally returns itself.
Flags `x ??= null`, which can never have an effect.
Flags `x ?? null` and `null ?? x`, where the `null` operand is redundant.
Flags `throw e` inside a `catch (e)` where `e` is exactly the caught exception.
Complexity
28 rules · 25 recommendedNeedlessly complex code that is harder to read and maintain.
Flags a function literal passed to `forEach`, e.g.
Flags a doubly-negated boolean expression such as `!!x`.
Flags a ternary conditional expression nested inside another ternary.
Flags an `if` statement whose then-branch contains nested `if` statements.
Flags an `async` function whose body is a single `return await ...;`.
Flags a `Container` whose only argument is a `child`.
Flags an `is` check whose result is already guaranteed by the declared type.
Flags an `as` cast to a type the operand already has.
Flags a function whose cyclomatic complexity exceeds the configured threshold.
Flags a file longer than the configured line limit.
Flags a function or method longer than the configured line limit.
Flags a function, method, or operator with more than the configured number of parameters.
Flags a `switch` statement with more than the configured number of cases.
Flags a function whose control-flow nesting runs deeper than the configured level.
Flags a comparison between a boolean value and a boolean literal, e.g.
Flags `if (x == null) { x = y; }` with no else branch.
Flags an `if`/`else` whose branches each reduce to a single return or a single assignment to the same target.
Flags an inline block-body callback passed to a widget constructor that should be extracted to a method.
Flags `Map.fromIterable(x, key: ..., value: ...)`.
Flags `x == null ? y : x` (and the inverted `x != null ? x : y`).
Flags a local variable that is returned on the immediately following statement.
Flags `iterable.where(...).isNotEmpty`.
Flags `!iterable.where(...).isEmpty` and `iterable.where(...).length == other.length`.
Flags a non-trivial expression duplicated across local variable initializers in the same block.
Flags `x == null ? null : x.y` (and the inverted `x != null ? x.y : null`).
Flags a redundant `const` keyword inside an already-const context.
Flags a trivial getter/setter pair that only reads and writes a private field.
Flags an `@override` member that does nothing but forward to `super` with the same arguments.
Performance
5 rules · 5 recommendedPatterns with avoidable runtime or build cost.
Flags `BorderRadius.only(...)` whose four corner radii are all equal.
Flags an `EdgeInsets.only(...)` that a more specific constructor expresses better.
Flags a constructor that could be declared `const` but is not.
Flags a `Container` used only to add fixed `width`/`height` whitespace.
Flags a `.toList()` call on the operand of a spread, e.g.
Style
72 rules · 67 recommendedIdiomatic, consistent Dart and Flutter style.
Flags Latin abbreviations in doc comments.
Flags explicit `= null` initializers on declarations that already default to null.
Flags use of the `late` keyword on variables and fields.
Flags the null-assertion operator `!`.
Flags positional fields in record types.
Flags redundant field names in object and record patterns.
Flags setters declared with an explicit return type.
Flags an expression statement that is a cascade with a single section.
Flags a `Column`, `Row`, or `Flex` widget built with a single child.
Flags mutable global state: non-`const`, non-`final` top-level variables and static fields, plus every read of them.
Flags comparison expressions with a literal on the left-hand side.
Flags boolean identifiers that lack a conventional interrogative prefix.
Flags named extensions whose name is not UpperCamelCase.
Flags type names that are not UpperCamelCase.
Flags class members declared out of a canonical order.
Flags constant identifiers that are not lowerCamelCase.
Requires curly braces around the bodies of flow-control statements.
Flags a file-level `///` doc comment that is not attached to any declaration.
Flags double literals written with redundant or missing digits.
Flags constructors with an empty block body `{}`.
Flags comments that are not formatted as complete sentences.
Flags import prefixes that are not `lower_case_with_underscores`.
Flags class members declared out of the configured order.
Flags `return` statements that are not preceded by a blank line.
Flags import prefixes that begin with an underscore.
Flags local variables and parameters whose names begin with an underscore.
Flags unnamed numeric literals (magic numbers) used inline in expressions.
Flags class members declared with the type `Object` (or `Object?`).
Flags non-constant identifiers that are not written in lowerCamelCase.
Flags two string literals joined with the `+` operator.
Flags `.then(...)` future chains that should use `async`/`await`.
Flags the type `Future<void> Function()` in favor of Flutter's `AsyncCallback`.
Flags no-argument collection constructor calls that a literal would express.
Flags declared identifiers that are shorter or longer than the allowed range.
Flags type declarations whose name is not well-formed UpperCamelCase.
Flags `MediaQuery.of(context).size` access in favor of `MediaQuery.sizeOf`.
Flags a private field that is initialized but never reassigned, so it could be `final`.
Flags `[0]` index access that should use the `.first` getter.
Flags a local variable bound to a function literal that should be a local function declaration.
Flags old-style function typedefs written with inline parameter syntax.
Flags a constructor that copies a plain parameter into a same-named field.
Flags an `add` cascade on a list literal whose element could be written inline.
Flags `.length` comparisons equivalent to a `.isEmpty` check.
Flags `.length` comparisons equivalent to a `.isNotEmpty` check.
Flags a negated type test `!(x is T)` that should use the `is!` operator.
Flags `.from` collection constructors in favor of the `.of` constructor.
Flags `.where((e) => e is T)`, which `.whereType<T>()` expresses directly.
Flags manual last-element indexing in favor of the `.last` getter.
Flags an `addAll` cascade on a collection literal that a spread would express.
Flags multi-line argument lists that are missing a trailing comma.
Flags uninitialized variables declared without a type annotation.
Flags unused closure parameters that are not named with underscores.
Flags `@deprecated` and `@Deprecated()` annotations that carry no message.
Flags `/** ...
Flags a `child` or `children` argument that is not the last named argument in a widget constructor call.
Flags a redundant type annotation on an initializing formal or super parameter.
Flags angle-bracket text in doc comments that Markdown would render as an HTML tag.
Flags `${x}` string interpolations whose braces can be dropped.
Flags a redundant `.new` on constructor invocations.
Flags a redundant `late` modifier on an initialized static or top-level variable.
Flags a `library` directive that carries an explicit name.
Flags an explicit `new` keyword in an instance-creation expression.
Flags a `final` or `const` variable given a nullable type but initialized to a provably non-null value.
Flags a backslash escape that has no effect on the string's value.
Flags a string literal whose entire content is a single interpolation.
Flags a redundant `this.` qualifier on member access.
Flags construction of a widget or type that should be replaced by its design-system equivalent.
Flags a `Color` constructed from a hexadecimal literal with fewer than eight digits.
Flags an old-style function-typed parameter written with inline parameter syntax.
Flags an `Expanded` wrapping an empty `SizedBox` or `Container` that should be a `Spacer`.
Flags a `part of` directive that names its library instead of using a string URI.
Flags a constructor parameter forwarded verbatim to `super(...)` and used nowhere else.
Cross-file rules
3 rules · 3 recommendedRules that analyze relationships between files across the whole project, run in falcon's whole-project pass.
Report nullable parameters of private declarations that never receive null.
Report public top-level declarations that nothing references.
Report `lib/` files that nothing in the project references.