Skip to main content

Rules

tip

General rules configuration is described here.

Rules are grouped by category to help you understand their purpose. Each rule has emojis denoting:

  • βš™οΈ - this rule is configurable
  • πŸ›  - some problems reported by this rule can be fixed by editor suggestions
  • ⚠️ - this rule is deprecated and will be removed in the next major release

Common​

arguments-ordering

Enforces named argument order in function and constructor invocations to be the same as corresponding named parameter declaration order.

added in: 5.1.0
style
βš™οΈπŸ› 
avoid-banned-imports

Configure some imports that you want to ban.

added in: 4.16.0
warning
βš™οΈ
avoid-cascade-after-if-null

Warns when a cascade expression is used after if null (??) binary expression without parentheses.

added in: 5.0.0
warning
avoid-collection-methods-with-unrelated-types

Avoid using collection methods with unrelated types, such as accessing a map of integers using a string key.

added in: 4.14.0
warning
avoid-double-slash-imports

Warns when an import/export directive contains a double slash.

added in: 5.2.0
warning
πŸ› 
avoid-duplicate-exports

Warns when a file has multiple exports declarations with the same URI.

added in: 4.17.0
warning
πŸ› 
avoid-dynamic

Warns when dynamic type is used as variable type in declaration, return type of a function, etc.

added in: 4.11.0
warning
avoid-global-state

Warns about usage mutable global variables.

added in: 4.10.0
warning
avoid-ignoring-return-values

Warns when a return value of a method or function invocation or a class instance property access is not used.

added in: 4.2.0
warning
avoid-late-keyword

Warns when a field or variable is declared with a late keyword.

added in: 3.2.0
warning
βš™οΈπŸ› 
avoid-missing-enum-constant-in-map

Warns when a enum constant is missing in a map declaration.

added in: 4.7.0
warning
avoid-nested-conditional-expressions

Warns about nested conditional expressions.

added in: 4.5.0
style
avoid-non-ascii-symbols

Warns when a string literal contains non ascii characters.

added in: 4.15.0
warning
avoid-non-null-assertion

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.

added in: 3.2.0
warning
avoid-passing-async-when-sync-expected

Warns when an asynchronous function is used as an argument where a synchronous function is expected.

added in: 4.18.0
warning
avoid-redundant-async

Checks for redundant async in a method or function body.

added in: 4.19.0
warning
πŸ› 
avoid-substring

Warns when a String.substring method is used.

added in: 5.7.0
warning
avoid-throw-in-catch-block

Warns when call throw in a catch block.

added in: 4.7.0
warning
avoid-top-level-members-in-tests

Warns when a public top-level member (except the entrypoint) is declared inside a test file.

added in: 4.17.0
warning
πŸ› 
avoid-unnecessary-conditionals

Checks for unnecessary conditional expressions.

added in: 5.2.0
warning
πŸ› 
avoid-unnecessary-type-assertions

Warns about unnecessary usage of is and whereType operators.

added in: 4.7.0
warning
avoid-unnecessary-type-casts

Warns about unnecessary usage of as operators.

added in: 4.7.0
warning
avoid-unrelated-type-assertions

Warns about unrelated usages of is operators.

added in: 4.9.0
warning
avoid-unused-parameters

Checks for unused parameters inside a function or method body.

added in: 2.4.0
warning
πŸ› 
ban-name

Configure some names that you want to ban.

added in: 4.12.0
warning
βš™οΈ
binary-expression-operand-order

Warns when a literal value is on the left hand side in a binary expressions.

added in: 1.7.0
style
πŸ› 
double-literal-format

Checks that double literals should begin with 0. instead of just ., and should not end with a trailing 0.

added in: 1.5.0
style
πŸ› 
format-comment

Prefer format comments like sentences.

added in: 4.11.0
style
βš™οΈπŸ› 
list-all-equatable-fields

Warns when a field is not added to props getter of a class that extends Equatable or EquatableMixin.

added in: 5.3.0
warning
πŸ› 
member-ordering

Enforces ordering for a class members.

added in: 1.8.0
style
βš™οΈπŸ› 
missing-test-assertion

Warns that there is no assertion in the test.

added in: 4.21.0
warning
βš™οΈ
newline-before-return

Enforces blank line between statements and return in a block.

added in: 1.5.1
style
βš™οΈπŸ› 
no-boolean-literal-compare

Warns on comparison to a boolean literal, as in x == true.

added in: 1.5.0
style
πŸ› 
no-empty-block

Disallows empty blocks except catch clause block.

added in: 1.5.1
style
no-equal-arguments

Warns when equal arguments are passed to a function or method invocation.

added in: 2.1.0
warning
βš™οΈ
no-equal-then-else

Warns when if statement has equal then and else statements or conditional expression has equal then and else expressions.

added in: 1.10.0
warning
πŸ› 
no-magic-number

Warns against using number literals outside of named constants or variables.

added in: 1.6.0
warning
βš™οΈ
no-object-declaration

Warns when a class member is declared with Object type.

added in: 1.8.0
style
prefer-async-await

Recommends to use async/await syntax to handle a Future result instead of .then() invocation.

added in: 4.11.0
style
prefer-commenting-analyzer-ignores

Warns when // ignore: comments are left without any additional description why this ignore is applied.

added in: 4.14.0
warning
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.

added in: 1.8.0
style
βš™οΈπŸ› 
prefer-correct-identifier-length

Warns when an identifier name length is very short or long.

added in: 4.5.0
style
βš™οΈ
prefer-correct-test-file-name

Warns if the file within /test contains a main, but the file name doesn't end with _test.dart.

added in: 4.19.0
warning
prefer-correct-type-name

Type name should only contain alphanumeric characters, start with an uppercase character and span between min-length and max-length characters in length.

added in: 4.5.0
style
βš™οΈ
prefer-enums-by-name

Since Dart 2.15 it's possible to use byName method on enum values prop instead of searching the value with firstWhere.

added in: 4.17.0
style
prefer-first

Use first to gets the first element.

added in: 4.5.0
style
πŸ› 
prefer-immediate-return

Warns when a method or a function returns a variable declared right before the return statement.

added in: 4.13.0
style
πŸ› 
prefer-iterable-of

Warns when List.from() factory is used instead of List.of().

added in: 4.19.0
warning
πŸ› 
prefer-last

Use last to gets the last element.

added in: 4.5.0
style
πŸ› 
prefer-match-file-name

Warns when a file name does not match the class name.

added in: 4.2.0
warning
πŸ› 
prefer-moving-to-variable

Warns when a property access or a method invocation start with duplicated chains of other invocations / accesses inside a single function or method block.

added in: 4.14.0
warning
βš™οΈ
prefer-static-class

Suggests to use static class member instead of global constants, variables and functions.

added in: 5.1.0
style
βš™οΈ
prefer-trailing-comma

Checks for a trailing comma for arguments, parameters, enum values and collections.

added in: 2.2.0
style
βš™οΈπŸ› 
tag-name

Warns when a tag name does not match the class name.

added in: 4.12.0
warning
βš™οΈπŸ› 

Flutter specific​

always-remove-listener

Warns when an event listener is added but never removed.

added in: 4.0.0
warning
avoid-border-all

Avoid using Border.all constructor.

added in: 4.11.0
performance
πŸ› 
avoid-returning-widgets

Warns when a method or function returns a Widget or subclass of a Widget.

added in: 3.1.0
warning
βš™οΈ
avoid-shrink-wrap-in-lists

Warns when a ListView widget with shrinkWrap parameter is wrapped in a Column, Row or another ListView widget.

added in: 4.17.0
performance
avoid-unnecessary-setstate

Warns when setState is called inside initState, didUpdateWidget or build methods and when it is called from a sync method that is called inside those methods.

added in: 4.0.0
warning
use-setstate-synchronously

Warns when setState is called past an await point.

added in: 5.4.0
warning
βš™οΈ
avoid-expanded-as-spacer

Avoid using Expanded widget as Spacer.

added in: 4.17.0
warning
πŸ› 
avoid-wrapping-in-padding

Warns when a widget is wrapped in a Padding widget but has a padding settings by itself.

added in: 4.0.0
warning
check-for-equals-in-render-object-setters

Warns when a RenderObject setter doesn't have an equality check for the new value.

added in: 4.19.0
warning
consistent-update-render-object

Warns when an updateRenderObject method is absent or doesn't update all fields set in createRenderObject.

added in: 4.19.0
warning
prefer-const-border-radius

Warns when a non-const border radius is used.

added in: 4.4.0
performance
πŸ› 
prefer-correct-edge-insets-constructor

Prefer correct EdgeInsets constructor.

added in: 4.17.0
style
πŸ› 
prefer-define-hero-tag

Warns when a Widget has an unset heroTag.

added in: 5.7.0
warning
prefer-extracting-callbacks

Warns about inline callbacks in a widget tree and suggest to extract them to a widget method.

added in: 4.0.0
style
βš™οΈ
prefer-single-widget-per-file

Warns when a file contains more than a single widget.

added in: 4.2.0
style
βš™οΈ
prefer-using-list-view

Warns when a Column widget with only children parameter is wrapped in a SingleChildScrollView widget.

added in: 5.2.0
performance

Flame​

Lints for the Flame package.

avoid-creating-vector-in-update

Warns when a Vector2 is created inside a Component's update method.

added in: 5.6.0
warning
avoid-initializing-in-on-mount

Warns when a late final variable is being initialized in the Component's onMount method.

added in: 5.6.0
warning
avoid-redundant-async-on-load

Warns when a Component's onLoad method can be made sync.

added in: 5.6.0
warning
πŸ› 
correct-game-instantiating

Warns when a game is instantiated in a stateless widget build method.

added in: 5.6.0
warning
πŸ› 

Intl specific​

prefer-intl-name

Recommends to use ClassName_ClassMemberName pattern for Intl methods name argument.

added in: 1.7.0
style
πŸ› 
prefer-provide-intl-description

Warns when a Intl method invoked without a description.

added in: 5.5.0
warning
provide-correct-intl-args

Warns when the Intl.message() invocation has incorrect args.

added in: 1.9.0
warning

Angular specific​

avoid-preserve-whitespace-false

Warns when a @Component annotation has explicit false value for preserveWhitespace.

added in: 1.5.1
warning
component-annotation-arguments-ordering

Enforces Angular @Component annotation arguments ordering.

added in: 1.9.0
style
βš™οΈ
prefer-on-push-cd-strategy

Prefer setting changeDetection: ChangeDetectionStrategy.OnPush in Angular @Component annotations.

added in: 1.8.0
warning