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

Dart​

-arguments-ordering

Enforces named argument order in function and constructor invocations to be the same as corresponding named parameter declaration order. style βš™οΈπŸ› 

-avoid-banned-imports

Configure some imports that you want to ban. warning βš™οΈ

-avoid-cascade-after-if-null

Warns when a cascade expression is used after if null (??) binary expression without parentheses. 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. warning

-avoid-double-slash-imports

Warns when an import/export directive contains a double slash. warning πŸ› 

-avoid-duplicate-exports

Warns when a file has multiple exports declarations with the same URI. warning πŸ› 

-avoid-dynamic

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

-avoid-global-state

Warns about usage mutable global variables. 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. warning

-avoid-late-keyword

Warns when a field or variable is declared with a late keyword. warning βš™οΈπŸ› 

-avoid-missing-enum-constant-in-map

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

-avoid-nested-conditional-expressions

Warns about nested conditional expressions. style

-avoid-non-ascii-symbols

Warns when a string literal contains non ascii characters. 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. warning

-avoid-passing-async-when-sync-expected

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

-avoid-redundant-async

Checks for redundant async in a method or function body. warning πŸ› 

-avoid-throw-in-catch-block

Warns when call throw in a catch block. warning

-avoid-top-level-members-in-tests

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

-avoid-unnecessary-conditionals

Checks for unnessesary conditional expressions. warning πŸ› 

-avoid-unnecessary-type-assertions

Warns about unnecessary usage of is and whereType operators. warning

-avoid-unnecessary-type-casts

Warns about unnecessary usage of as operators. warning

-avoid-unrelated-type-assertions

Warns about unrelated usages of is operators. warning

-avoid-unused-parameters

Checks for unused parameters inside a function or method body. warning πŸ› 

-ban-name

Configure some names that you want to ban. warning βš™οΈ

-binary-expression-operand-order

Warns when a literal value is on the left hand side in a binary expressions. style πŸ› 

-double-literal-format

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

-format-comment

Prefer format comments like sentences. style βš™οΈπŸ› 

-list-all-equatable-fields

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

-member-ordering

Enforces ordering for a class members. style βš™οΈπŸ› 

-missing-test-assertion

Warns that there is no assertion in the test. warning βš™οΈ

-newline-before-return

Enforces blank line between statements and return in a block. style βš™οΈπŸ› 

-no-boolean-literal-compare

Warns on comparison to a boolean literal, as in x == true. style πŸ› 

-no-empty-block

Disallows empty blocks except catch clause block. style

-no-equal-arguments

Warns when equal arguments are passed to a function or method invocation. warning βš™οΈ

-no-equal-then-else

Warns when if statement has equal then and else statements or conditional expression has equal then and else expressions. warning πŸ› 

-no-magic-number

Warns against using number literals outside of named constants or variables. warning βš™οΈ

-no-object-declaration

Warns when a class member is declared with Object type. style

-prefer-async-await

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

-prefer-commenting-analyzer-ignores

Warns when // ignore: comments are left without any additional description why this ignore is applied. 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. style βš™οΈπŸ› 

-prefer-correct-identifier-length

Warns when an identifier name length is very short or long. 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. 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. 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. style

-prefer-first

Use first to gets the first element. style πŸ› 

-prefer-immediate-return

Warns when a method or a function returns a variable declared right before the return statement. style πŸ› 

-prefer-iterable-of

Warns when List.from() factory is used instead of List.of(). warning πŸ› 

-prefer-last

Use last to gets the last element. style πŸ› 

-prefer-match-file-name

Warns when a file name does not match the class name. 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. warning βš™οΈ

-prefer-static-class

Suggests to use static class member instead of global constants, variables and functions. style βš™οΈ

-prefer-trailing-comma

Checks for a trailing comma for arguments, parameters, enum values and collections. style βš™οΈπŸ› 

-tag-name

Warns when a tag name does not match the class name. warning βš™οΈπŸ› 

Flutter specific​

-always-remove-listener

Warns when an event listener is added but never removed. warning

-avoid-border-all

Avoid using Border.all constructor. performance πŸ› 

-avoid-returning-widgets

Warns when a method or function returns a Widget or subclass of a Widget. warning βš™οΈ

-avoid-shrink-wrap-in-lists

Warns when a ListView widget with shrinkWrap parameter is wrapped in a Column, Row or another ListView widget. 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. warning

-use-setstate-synchronously

Warns when setState is called past an await point. warning βš™οΈ

-avoid-expanded-as-spacer

Avoid using Expanded widget as Spacer. warning πŸ› 

-avoid-wrapping-in-padding

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

-check-for-equals-in-render-object-setters

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

-consistent-update-render-object

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

-prefer-const-border-radius

Warns when a non-const border radius is used. performance πŸ› 

-prefer-correct-edge-insets-constructor

Prefer correct EdgeInsets constructor. style πŸ› 

-prefer-extracting-callbacks

Warns about inline callbacks in a widget tree and suggest to extract them to a widget method. style βš™οΈ

-prefer-single-widget-per-file

Warns when a file contains more than a single widget. style βš™οΈ

-prefer-using-list-view

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

Flame​

Lints for the Flame package.

-avoid-creating-vector-in-update

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

-avoid-initializing-in-on-mount

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

-avoid-redundant-async-on-load

Warns when a Component's onLoad method can be made sync. warning πŸ› 

Intl specific​

-prefer-intl-name

Recommends to use ClassName_ClassMemberName pattern for Intl methods name argument. style πŸ› 

-prefer-provide-intl-description

Warns when a Intl method invoked without a description. warning