Rules

148 rules across 5 groups, 140 recommended. 3 run across the whole project graph.

Correctness

18 rules · 18 recommended

Code that is outright wrong or will not behave as intended.

avoid-global-staterecommended

Disallow mutable global and static state.

avoid-mutable-global-variablesrecommended

Disallow mutable top-level variables.

avoid-relative-lib-importsrecommended

Disallow relative imports that reach into a `lib/` directory.

avoid-returning-widgetsrecommendedflutter

Disallow functions and methods that return a `Widget`.

avoid-unused-parametersrecommended

Disallow declared parameters that are never used.

avoid-web-libraries-in-flutterrecommendedflutter

Disallow importing web-only `dart:` libraries from Flutter code.

correct-order-for-super-disposerecommendedflutter

Require `super.dispose()` to be the last call in `dispose`.

hash-and-equalsrecommended

Require `hashCode` and `==` to be overridden together.

implementation-importsrecommended

Disallow importing another package's private `src/` files.

no-logic-in-create-staterecommendedflutter

Require `createState` to do nothing but return a new `State` instance.

proper-controller-disposerecommendedflutter

Require controllers owned by a `State` to be disposed.

proper-expanded-and-flexiblerecommendedflutter

Require `Expanded` and `Flexible` to sit directly inside a flex widget.

proper-from-environmentrecommended

Require `fromEnvironment` to be evaluated in a const context.

proper-super-init-staterecommendedflutter

Require `super.initState()` to be the first call in `initState`.

unnecessary-flutter-importsrecommendedflutter

Disallow Flutter framework imports that the file does not use.

unnecessary-nullable-return-typerecommended

Disallow nullable return types on functions that never return null.

use-once-constructors-once-providerrecommendedflutter

Require Riverpod once-providers to be created through `.once()`.

valid-regexpsrecommended

Disallow `RegExp` patterns that are structurally invalid.

Suspicious

22 rules · 22 recommended

Patterns that are probably a mistake or a latent bug.

avoid-dynamicrecommended

Flags explicit `dynamic` type annotations.

avoid-empty-elserecommended

Flags an `else` clause whose body is an empty statement (`else ;`).

avoid-ignoring-return-valuesrecommended

Flags a call whose non-void return value is discarded.

avoid-passing-async-when-sync-expectedrecommended

Flags an `async` function literal passed where a synchronous callback is expected.

avoid-printrecommendedflutter

Flags calls to the top-level `print` function.

avoid-returning-null-for-voidrecommended

Flags `return null;` (and `=> null` bodies) in a function whose declared return type is `void` or `Future<void>`.

avoid-shadowing-type-parametersrecommended

Flags a type parameter that shadows a type parameter of an enclosing declaration.

avoid-throw-in-catch-blockrecommended

Flags a `throw` of a new object inside a `catch` block.

avoid-unrelated-type-assertionsrecommended

Flags an `is` check that can never succeed because the operand's type is unrelated to the tested type.

control-flow-in-finallyrecommended

Flags `return`, `break`, or `continue` that escapes a `finally` block.

empty-catchesrecommended

Flags empty `catch` blocks.

empty-statementsrecommended

Flags stray empty statements (a lone `;`).

no-duplicate-case-valuesrecommended

Flags a switch `case` whose value duplicates an earlier case in the same switch.

no-empty-blockrecommended

Flags empty blocks (`{}`).

no-equal-argumentsrecommended

Flags an argument passed more than once in the same invocation.

no-equal-then-elserecommended

Flags an `if`/`else` or ternary whose two branches are identical.

no-self-comparisonsrecommended

Flags a comparison whose two operands are identical.

no-wildcard-variable-usesrecommended

Flags references to a wildcard variable or parameter (a name made solely of underscores, such as `_` or `__`).

recursive-gettersrecommended

Flags a getter that unconditionally returns itself.

unnecessary-null-aware-assignmentsrecommended

Flags `x ??= null`, which can never have an effect.

unnecessary-null-in-if-null-operatorsrecommended

Flags `x ?? null` and `null ?? x`, where the `null` operand is redundant.

use-rethrow-when-possiblerecommended

Flags `throw e` inside a `catch (e)` where `e` is exactly the caught exception.

Complexity

28 rules · 25 recommended

Needlessly complex code that is harder to read and maintain.

avoid-function-literals-in-foreach-calls

Flags a function literal passed to `forEach`, e.g.

avoid-inverted-boolean-expressionsrecommended

Flags a doubly-negated boolean expression such as `!!x`.

avoid-nested-conditional-expressionsrecommended

Flags a ternary conditional expression nested inside another ternary.

avoid-nested-ifrecommended

Flags an `if` statement whose then-branch contains nested `if` statements.

avoid-redundant-asyncrecommended

Flags an `async` function whose body is a single `return await ...;`.

avoid-unnecessary-containersrecommendedflutter

Flags a `Container` whose only argument is a `child`.

avoid-unnecessary-type-assertionsrecommended

Flags an `is` check whose result is already guaranteed by the declared type.

avoid-unnecessary-type-castsrecommended

Flags an `as` cast to a type the operand already has.

cyclomatic-complexityrecommended

Flags a function whose cyclomatic complexity exceeds the configured threshold.

max-lines-for-filerecommended

Flags a file longer than the configured line limit.

max-lines-for-functionrecommended

Flags a function or method longer than the configured line limit.

max-parameters-for-functionrecommended

Flags a function, method, or operator with more than the configured number of parameters.

max-switch-casesrecommended

Flags a `switch` statement with more than the configured number of cases.

maximum-nesting-levelrecommended

Flags a function whose control-flow nesting runs deeper than the configured level.

no-boolean-literal-comparerecommended

Flags a comparison between a boolean value and a boolean literal, e.g.

prefer-conditional-assignmentrecommended

Flags `if (x == null) { x = y; }` with no else branch.

prefer-conditional-expressionsrecommended

Flags an `if`/`else` whose branches each reduce to a single return or a single assignment to the same target.

prefer-extracting-callbacksrecommendedflutter

Flags an inline block-body callback passed to a widget constructor that should be extracted to a method.

prefer-for-elements-to-map-from-iterable

Flags `Map.fromIterable(x, key: ..., value: ...)`.

prefer-if-null-operatorsrecommended

Flags `x == null ? y : x` (and the inverted `x != null ? x : y`).

prefer-immediate-returnrecommended

Flags a local variable that is returned on the immediately following statement.

prefer-iterable-anyrecommended

Flags `iterable.where(...).isNotEmpty`.

prefer-iterable-everyrecommended

Flags `!iterable.where(...).isEmpty` and `iterable.where(...).length == other.length`.

prefer-moving-to-variablerecommended

Flags a non-trivial expression duplicated across local variable initializers in the same block.

prefer-null-aware-operatorsrecommended

Flags `x == null ? null : x.y` (and the inverted `x != null ? x.y : null`).

unnecessary-const

Flags a redundant `const` keyword inside an already-const context.

unnecessary-getters-settersrecommended

Flags a trivial getter/setter pair that only reads and writes a private field.

unnecessary-overridesrecommended

Flags an `@override` member that does nothing but forward to `super` with the same arguments.

Performance

5 rules · 5 recommended

Patterns with avoidable runtime or build cost.

prefer-const-border-radiusrecommendedflutter

Flags `BorderRadius.only(...)` whose four corner radii are all equal.

prefer-correct-edge-insets-constructorrecommendedflutter

Flags an `EdgeInsets.only(...)` that a more specific constructor expresses better.

prefer-declaring-const-constructorrecommendedflutter

Flags a constructor that could be declared `const` but is not.

sized-box-for-whitespacerecommendedflutter

Flags a `Container` used only to add fixed `width`/`height` whitespace.

unnecessary-to-list-in-spreadsrecommended

Flags a `.toList()` call on the operand of a spread, e.g.

Style

72 rules · 67 recommended

Idiomatic, consistent Dart and Flutter style.

avoid-abbreviations-in-doc-commentsrecommended

Flags Latin abbreviations in doc comments.

avoid-init-to-nullrecommended

Flags explicit `= null` initializers on declarations that already default to null.

avoid-late-keywordrecommended

Flags use of the `late` keyword on variables and fields.

avoid-non-null-assertionrecommended

Flags the null-assertion operator `!`.

avoid-positional-fields-in-recordsrecommended

Flags positional fields in record types.

avoid-redundant-pattern-field-namesrecommended

Flags redundant field names in object and record patterns.

avoid-return-types-on-settersrecommended

Flags setters declared with an explicit return type.

avoid-single-cascade-in-expression-statementsrecommended

Flags an expression statement that is a cascade with a single section.

avoid-single-child-column-or-rowrecommendedflutter

Flags a `Column`, `Row`, or `Flex` widget built with a single child.

avoid-top-level-member-accessrecommended

Flags mutable global state: non-`const`, non-`final` top-level variables and static fields, plus every read of them.

binary-expression-operand-orderrecommended

Flags comparison expressions with a literal on the left-hand side.

boolean-prefixesrecommended

Flags boolean identifiers that lack a conventional interrogative prefix.

camel-case-extensionsrecommended

Flags named extensions whose name is not UpperCamelCase.

camel-case-typesrecommended

Flags type names that are not UpperCamelCase.

class-members-orderingrecommended

Flags class members declared out of a canonical order.

constant-identifier-namesrecommended

Flags constant identifiers that are not lowerCamelCase.

curly-braces-in-flow-control-structuresrecommended

Requires curly braces around the bodies of flow-control statements.

dangling-library-doc-commentsrecommended

Flags a file-level `///` doc comment that is not attached to any declaration.

double-literal-formatrecommended

Flags double literals written with redundant or missing digits.

empty-constructor-bodiesrecommended

Flags constructors with an empty block body `{}`.

format-commentrecommended

Flags comments that are not formatted as complete sentences.

library-prefixesrecommended

Flags import prefixes that are not `lower_case_with_underscores`.

member-orderingrecommended

Flags class members declared out of the configured order.

newline-before-returnrecommended

Flags `return` statements that are not preceded by a blank line.

no-leading-underscores-for-library-prefixesrecommended

Flags import prefixes that begin with an underscore.

no-leading-underscores-for-local-identifiersrecommended

Flags local variables and parameters whose names begin with an underscore.

no-magic-numberrecommended

Flags unnamed numeric literals (magic numbers) used inline in expressions.

no-object-declarationrecommended

Flags class members declared with the type `Object` (or `Object?`).

non-constant-identifier-namesrecommended

Flags non-constant identifiers that are not written in lowerCamelCase.

prefer-adjacent-string-concatenationrecommended

Flags two string literals joined with the `+` operator.

prefer-async-awaitrecommended

Flags `.then(...)` future chains that should use `async`/`await`.

prefer-async-callbackrecommendedflutter

Flags the type `Future<void> Function()` in favor of Flutter's `AsyncCallback`.

prefer-collection-literals

Flags no-argument collection constructor calls that a literal would express.

prefer-correct-identifier-lengthrecommended

Flags declared identifiers that are shorter or longer than the allowed range.

prefer-correct-type-namerecommended

Flags type declarations whose name is not well-formed UpperCamelCase.

prefer-dedicated-media-query-methodsrecommendedflutter

Flags `MediaQuery.of(context).size` access in favor of `MediaQuery.sizeOf`.

prefer-final-fieldsrecommended

Flags a private field that is initialized but never reassigned, so it could be `final`.

prefer-firstrecommended

Flags `[0]` index access that should use the `.first` getter.

prefer-function-declarations-over-variablesrecommended

Flags a local variable bound to a function literal that should be a local function declaration.

prefer-generic-function-type-aliasesrecommended

Flags old-style function typedefs written with inline parameter syntax.

prefer-initializing-formalsrecommended

Flags a constructor that copies a plain parameter into a same-named field.

prefer-inlined-addsrecommended

Flags an `add` cascade on a list literal whose element could be written inline.

prefer-is-empty

Flags `.length` comparisons equivalent to a `.isEmpty` check.

prefer-is-not-empty

Flags `.length` comparisons equivalent to a `.isNotEmpty` check.

prefer-is-not-operatorrecommended

Flags a negated type test `!(x is T)` that should use the `is!` operator.

prefer-iterable-ofrecommended

Flags `.from` collection constructors in favor of the `.of` constructor.

prefer-iterable-where-typerecommended

Flags `.where((e) => e is T)`, which `.whereType<T>()` expresses directly.

prefer-lastrecommended

Flags manual last-element indexing in favor of the `.last` getter.

prefer-spread-collectionsrecommended

Flags an `addAll` cascade on a collection literal that a spread would express.

prefer-trailing-commarecommended

Flags multi-line argument lists that are missing a trailing comma.

prefer-typing-uninitialized-variablesrecommended

Flags uninitialized variables declared without a type annotation.

prefer-underscore-for-unused-callback-parametersrecommended

Flags unused closure parameters that are not named with underscores.

provide-deprecation-messagerecommended

Flags `@deprecated` and `@Deprecated()` annotations that carry no message.

slash-for-doc-commentsrecommended

Flags `/** ...

sort-child-properties-lastrecommendedflutter

Flags a `child` or `children` argument that is not the last named argument in a widget constructor call.

type-init-formalsrecommended

Flags a redundant type annotation on an initializing formal or super parameter.

unintended-html-in-doc-commentrecommended

Flags angle-bracket text in doc comments that Markdown would render as an HTML tag.

unnecessary-brace-in-string-interpsrecommended

Flags `${x}` string interpolations whose braces can be dropped.

unnecessary-constructor-namerecommended

Flags a redundant `.new` on constructor invocations.

unnecessary-laterecommended

Flags a redundant `late` modifier on an initialized static or top-level variable.

unnecessary-library-namerecommended

Flags a `library` directive that carries an explicit name.

unnecessary-newrecommended

Flags an explicit `new` keyword in an instance-creation expression.

unnecessary-nullable-for-final-variable-declarations

Flags a `final` or `const` variable given a nullable type but initialized to a provably non-null value.

unnecessary-string-escapesrecommended

Flags a backslash escape that has no effect on the string's value.

unnecessary-string-interpolationsrecommended

Flags a string literal whose entire content is a single interpolation.

unnecessary-thisrecommended

Flags a redundant `this.` qualifier on member access.

use-design-system-itemrecommendedflutter

Flags construction of a widget or type that should be replaced by its design-system equivalent.

use-full-hex-values-for-flutter-colorsrecommendedflutter

Flags a `Color` constructed from a hexadecimal literal with fewer than eight digits.

use-function-type-syntax-for-parametersrecommended

Flags an old-style function-typed parameter written with inline parameter syntax.

use-spacer-as-expanded-childrecommendedflutter

Flags an `Expanded` wrapping an empty `SizedBox` or `Container` that should be a `Spacer`.

use-string-in-part-of-directivesrecommended

Flags a `part of` directive that names its library instead of using a string URI.

use-super-parameters

Flags a constructor parameter forwarded verbatim to `super(...)` and used nowhere else.

Cross-file rules

3 rules · 3 recommended

Rules that analyze relationships between files across the whole project, run in falcon's whole-project pass.

unnecessary-nullablerecommendedcross-file

Report nullable parameters of private declarations that never receive null.

unused-coderecommendedcross-file

Report public top-level declarations that nothing references.

unused-filesrecommendedcross-file

Report `lib/` files that nothing in the project references.