Rules overview
Rules are grouped by a category to help you understand their purpose.
Rules configuration is described here.
Common
avoid-collection-methods-with-unrelated-types
Avoid using collection methods with unrelated types, such as accessing a map of integers using a string key.
Warns when
dynamic
type is used as variable type in declaration, return type of a function, etc.Warns about usage mutable global variables.
Warns when a return value of a method or function invocation or a class instance property access is not used.
Warns when a field or variable is declared with a
late
keyword.avoid-missing-enum-constant-in-map
Warns when a enum constant is missing in a map declaration.
avoid-nested-conditional-expressions
Warns about nested conditional expressions.
Warns when a string literal contains non ascii characters.
Warns when non null assertion operator (or “bang” operator) is used for a property access or method invocation. The operator check works at runtime and it may fail and throw a runtime exception.
Warns when call
throw
in a catch block.avoid-unnecessary-type-assertions
Warns about unnecessary usage of 'is' and 'whereType' operators.
Warns about unnecessary usage of 'as' operators.
avoid-unrelated-type-assertions
Warns about unrelated usages of 'is' operators.
Checks for unused parameters inside a function or method body.
Configure some names that you want to ban.
binary-expression-operand-order
Warns when a literal value is on the left hand side in a binary expressions.
Checks that double literals should begin with
0.
instead of just.
, and should not end with a trailing0
.Prefer format comments like sentences.
Enforces ordering for a class members.
Enforces ordering for a class members.
Enforces blank line between statements and return in a block.
Warns on comparison to a boolean literal, as in x == true.
Disallows empty blocks except catch clause block.
Warns when equal arguments passed to a function or method invocation.
Warns when if statement has equal then and else statements or conditional expression has equal then and else expressions.
Warns against using number literals outside of named constants or variables.
Warns when a class member is declared with Object type.
Recommends to use async/await syntax to handle Futures result instead of
.then()
invocation.prefer-commenting-analyzer-ignores
Warns when
// ignore:
comments are left without any additional description why this ignore is applied.prefer-conditional-expressions
Recommends to use a conditional expression instead of assigning to the same thing or return statement in each branch of an if statement.
prefer-correct-identifier-length
Warns when identifier name length very short or long.
Type name should only contain alphanumeric characters, start with an uppercase character and span between min-length and max-length characters in length.
Use
first
to gets the first element.Warns when a method or a function returns a variable declared right before the return statement.
Use
last
to gets the last element.Warns when file name does not match class name.
Check for trailing comma for arguments, parameters, enum values and collections.
Warns when tag name does not match class name.
Flutter specific
Warns when an event listener is added but never removed.
Avoid using Border.all constructor.
Warns when a method or function returns a Widget or subclass of a Widget.
Warns when
setState
is called insideinitState
,didUpdateWidget
orbuild
methods and when it is called from async
method that is called inside those methods.Warns when a widget is wrapped in a Padding widget but has a padding settings by itself.
Warns when used non const border radius.
Warns about inline callbacks in a widget tree and suggest to extract them to a widget method.
Warns when a file contains more than a single widget.
Intl specific
Recommends to use ClassName_ClassMemberName pattern for Intl methods name argument.
Warns when the Intl.message() invocation has incorrect args.
Angular specific
avoid-preserve-whitespace-false
Warns when a
@Component
annotation has explicit false value for preserveWhitespace.component-annotation-arguments-ordering
Enforces Angular
@Component
annotation arguments ordering.Prefer setting changeDetection: ChangeDetectionStrategy.OnPush in Angular
@Component
annotations.