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

You can also suggest a rule!

Categories
All
Presets
All
Severities
All
Versions
All
Config
Unset
Fixes
Unset

Common 215 rules

arguments-ordering

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

added in: 1.6.0
style
⚙️🛠
avoid-accessing-collections-by-constant-index

Warns when a collection is accessed by a constant index inside a for loop.

added in: 1.10.0
warning
preset: recommended
avoid-accessing-other-classes-private-members

Warns when a private member of another class is used.

added in: 1.7.0
warning
avoid-async-call-in-sync-function

Warns when an async function is invoked in non-async blocks.

added in: 1.8.0
warning
avoid-banned-annotations

Configure annotations that you want to ban.

added in: 1.11.0
warning
⚙️🛠
avoid-banned-file-names

Configure file names that you want to ban.

added in: 1.4.0
warning
⚙️
avoid-banned-imports

Configure imports that you want to ban.

added in: 1.6.0
warning
⚙️🛠
avoid-banned-types

Configure types that you want to ban.

added in: 1.4.0
warning
⚙️
avoid-barrel-files

Warns when a file is a barrel file.

added in: 1.7.0
warning
avoid-bottom-type-in-patterns

Warns when a pattern contains a void,Never or Null type.

added in: 1.5.0
warning
avoid-bottom-type-in-records

Warns when a record type declaration contains fields with void, Never or Null.

added in: 1.5.0
warning
avoid-cascade-after-if-null

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

added in: 1.6.0
warning
🛠
preset: recommended
avoid-casting-to-extension-type

Warns when an expression is cast to an extension type.

added in: 1.15.0
warning
avoid-collapsible-if

Warns when multiple nested if statements can be merged into one.

added in: 1.1.0
style
🛠
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: 1.6.0
warning
preset: recommended
avoid-collection-mutating-methods

Warns when a mutating method is called on a collection.

added in: 1.11.0
warning
⚙️
avoid-contradictory-expressions

Warns when several conditions contradict each other.

added in: 1.14.0
warning
avoid-declaring-call-method

Warns when a class has a call method.

added in: 1.3.0
warning
🛠
avoid-double-slash-imports

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

added in: 1.6.0
warning
🛠
preset: recommended
avoid-duplicate-cascades

Warns when a cascade expression has duplicate cascades.

added in: 1.11.0
warning
🛠
preset: recommended
avoid-duplicate-collection-elements

Warns when a collection has duplicate collection elements.

added in: 1.13.0
warning
avoid-duplicate-exports

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

added in: 1.6.0
warning
🛠
preset: recommended
avoid-duplicate-initializers

Warns when a final variable has the same initializer as another variable in scope.

added in: 1.13.0
warning
preset: recommended
avoid-duplicate-map-keys

Warns when a map has duplicate keys.

added in: 1.13.0
warning
🛠
preset: recommended
avoid-duplicate-mixins

Warns when a class has a mixin that is already present in that class's hierarchy.

added in: 1.8.0
warning
🛠
preset: recommended
avoid-duplicate-named-imports

Warns when a file has duplicate imports which differ only in name prefix.

added in: 1.2.0
warning
avoid-duplicate-patterns

Warns when a LogicalOrPattern or LogicalAndPattern contains duplicate patterns.

added in: 1.5.0
warning
preset: recommended
avoid-duplicate-switch-case-conditions

Warns when several switch cases have the same condition.

added in: 1.11.0
warning
preset: recommended
avoid-duplicate-test-assertions

Warns when a test case has multiple test assertions with the same expression and expected value.

added in: 1.12.0
warning
🛠
preset: recommended
avoid-dynamic

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

added in: 1.6.0
warning
preset: recommended
avoid-empty-spread

Warns when a collection literal in spread (...[]) has no elements.

added in: 1.15.0
warning
🛠
avoid-empty-test-groups

Warns when a test group does not have any test cases.

added in: 1.14.0
warning
⚙️🛠
avoid-equal-expressions

Warns when both sides of a binary expression are the same.

added in: 1.3.0
warning
🛠
preset: recommended
avoid-excessive-expressions

Warns when a condition has excessive expressions.

added in: 1.14.0
warning
avoid-explicit-pattern-field-name

Warns when an object pattern has an explicit field name.

added in: 1.5.0
warning
🛠
preset: recommended
avoid-explicit-type-declaration

Warns when a variable is declared with an explicit type that can be omitted.

added in: 1.1.0
style
🛠
avoid-extensions-on-records

Warns when an extension is declared on a record type.

added in: 1.10.0
warning
avoid-function-type-in-records

Warns when a record type declaration contains a function type.

added in: 1.5.0
style
avoid-future-tostring

Warns when a Future is a target of the toString method or is used in an interpolation.

added in: 1.6.0
warning
preset: recommended
avoid-generics-shadowing

Warns when a generic type shadows and existing top-level (class, mixin, typedef or enum) declaration.

added in: 1.7.0
warning
preset: recommended
avoid-global-state

Warns about usage mutable global variables.

added in: 1.6.0
warning
avoid-identical-exception-handling-blocks

Warns when a try / catch has multiple catch blocks with the same body.

added in: 1.9.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: 1.6.0
warning
avoid-importing-entrypoint-exports

Warns when an entrypoint export is imported inside the library src folder.

added in: 1.7.0
style
⚙️🛠
avoid-inferrable-type-arguments

Warns when an inferrable type argument can be removed without affecting the code.

added in: 1.11.0
style
⚙️🛠
preset: recommended
avoid-inverted-boolean-checks

Warns when a condition has an inverted check.

added in: 1.4.0
style
avoid-keywords-in-wildcard-pattern

Warns when a wildcard pattern has declaration keywords.

added in: 1.7.0
style
🛠
preset: recommended
avoid-late-keyword

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

added in: 1.6.0
warning
⚙️🛠
avoid-local-functions

Warns when a function declaration is a local function.

added in: 1.10.0
style
avoid-long-functions

Warns when a function or method has a too long body.

added in: 1.2.0
warning
⚙️
avoid-long-files

Warns when a file length (number of lines) exceeds the configured maximum.

added in: 1.10.0
warning
⚙️
avoid-long-parameter-list

Warns when a function or method has a too long parameter list.

added in: 1.2.0
warning
⚙️
avoid-long-records

Warns when a record has too many fields.

added in: 1.5.0
warning
⚙️
avoid-map-keys-contains

Warns when Map's .keys.contains is used instead of containsKey.

added in: 1.8.0
warning
🛠
preset: recommended
avoid-missed-calls

Warns when a method that should be invoked is passed as tear-off.

added in: 1.3.0
warning
🛠
preset: recommended
avoid-missed-calls

Warns when Completer.completeError is called without providing a stack trace.

added in: 1.15.0
warning
avoid-missing-enum-constant-in-map

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

added in: 1.6.0
warning
preset: recommended
avoid-missing-interpolation

Warns when a string equals to a variable name that is available in the current scope but is not wrapped into an interpolation.

added in: 1.9.0
warning
avoid-missing-test-files

Configure a list of files that should have a corresponding test file.

added in: 1.11.0
warning
⚙️
avoid-misused-test-matchers

Warns when an incorrect matcher or literal is used to verify the target expression.

added in: 1.12.0
warning
preset: recommended
avoid-misused-wildcard-pattern

Warns when a wildcard pattern is used in the wrong context.

added in: 1.7.0
warning
avoid-mixing-named-and-positional-fields

Warns when a method that should be invoked is passed as tear-off.

added in: 1.5.0
style
avoid-mutating-parameters

Warns when a parameter's field or setter is reassigned.

added in: 1.7.0
warning
avoid-negated-conditions

Warns when an if statement or conditional expression have a negated condition that can be inverted.

added in: 1.7.0
style
🛠
avoid-nested-conditional-expressions

Warns about nested conditional expressions.

added in: 1.6.0
style
avoid-nested-extension-types

Warns when the representation field of an extension type is also an extension type.

added in: 1.15.0
style
⚙️
avoid-nested-futures

Warns when a Future type contains another Future.

added in: 1.7.0
warning
preset: recommended
avoid-nested-records

Warns when a record type declaration contains a nested record type declaration.

added in: 1.5.0
style
⚙️
preset: recommended
avoid-nested-streams-and-futures

Warns when a Stream type contains a Future or vice versa.

added in: 1.7.0
warning
avoid-nested-switch-expressions

Warns when a switch expression contains another switch expression.

added in: 1.5.0
style
⚙️
avoid-nested-switches

Warns when a switch case body has another switch statement.

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

Warns when a string literal contains non ascii characters.

added in: 1.6.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: 1.6.0
warning
⚙️
avoid-not-encodable-in-to-json

Warns when a toJson method references a non-encodable object.

added in: 1.14.0
warning
avoid-nullable-interpolation

Warns when an interpolation string contains a nullable value.

added in: 1.8.0
warning
⚙️
preset: recommended
avoid-nullable-parameters-with-default-values

Warns when a parameter with the default value is marked as nullable.

added in: 1.10.0
warning
🛠
preset: recommended
avoid-nullable-tostring

Warns when the toString method is called on a nullable value.

added in: 1.13.0
warning
🛠
preset: recommended
avoid-one-field-records

Warns when a record has only one field.

added in: 1.5.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: 1.6.0
warning
preset: recommended
avoid-passing-default-values

Warns when an invocation has an argument that matches the parameter's default value.

added in: 1.9.0
warning
⚙️🛠
avoid-passing-self-as-argument

Warns when an object is used as an argument to its own method.

added in: 1.9.0
warning
preset: recommended
avoid-positional-record-field-access

Warns when a record positional field is accessed via $.

added in: 1.5.0
warning
avoid-recursive-calls

Warns when a function calls itself recursively.

added in: 1.9.0
warning
avoid-redundant-async

Checks for redundant async in a method or function body.

added in: 1.6.0
warning
🛠
preset: recommended
avoid-redundant-else

Checks for else blocks that can be removed without changing semantics.

added in: 1.1.0
style
🛠
preset: recommended
avoid-redundant-positional-field-name

Warns when a record positional field has a name.

added in: 1.5.0
warning
🛠
preset: recommended
avoid-redundant-pragma-inline

Warns when a @pragma('vm:prefer-inline') annotation has no effect.

added in: 1.4.0
warning
🛠
preset: recommended
avoid-referencing-discarded-variables

Warns when a variable with the name that has only underscores (ex. _, __, etc.) is referenced.

added in: 1.9.0
warning
preset: recommended
avoid-renaming-representation-getters

Warns when an extension type exposes a member that renames an existing representation field member.

added in: 1.15.0
warning
🛠
avoid-returning-void

Suggests calling functions or methods with a void return type separately from the return statement.

added in: 1.15.0
style
🛠
avoid-self-assignment

Warns when a variable or a class instance field / property is assigned to itself.

added in: 1.1.0
warning
🛠
preset: recommended
avoid-self-compare

Warns when a comparison has both sides exactly the same.

added in: 1.1.0
warning
preset: recommended
avoid-shadowed-extension-methods

Warns when an extension declares a method with the name that is already used by the extension target.

added in: 1.7.0
warning
preset: recommended
avoid-shadowing

Warns when a declaration name shadows another declaration with the same name in the current scope.

added in: 1.2.0
warning
⚙️
preset: recommended
avoid-similar-names

Checks for names within the scope that are very similar and thus confusing.

added in: 1.1.0
style
⚙️
avoid-slow-collection-methods

Warns when an invocation is a slow sync* invocation.

added in: 1.15.0
performance
avoid-substring

Warns when a String.substring method is used.

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

Warns when call throw in a catch block.

added in: 1.6.0
warning
preset: recommended
avoid-throw-objects-without-tostring

Warns when a thrown object does not implement toString.

added in: 1.4.0
warning
preset: recommended
avoid-top-level-members-in-tests

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

added in: 1.6.0
warning
🛠
avoid-unassigned-late-fields

Warns when a late field is not assigned a value.

added in: 1.6.0
warning
preset: recommended
avoid-unassigned-stream-subscriptions

Warns when a stream subscription is not assigned to a variable.

added in: 1.13.0
warning
preset: recommended
avoid-uncaught-future-errors

Warns when an error from a Future inside a try / catch block might not be caught.

added in: 1.7.0
warning
preset: recommended
avoid-unconditional-break

Warns when a break, continue, return or throw are used unconditionally in a for loop.

added in: 1.9.0
warning
preset: recommended
avoid-unknown-pragma

Warns when the @pragma annotation has an unknown value.

added in: 1.15.0
warning
avoid-unnecessary-call

Warns when a .call() invocation is unnecessary and can be simplified.

added in: 1.7.0
style
preset: recommended
avoid-unnecessary-collections

Warns when a collection literal can be replaced by its first and only element.

added in: 1.15.0
warning
avoid-unnecessary-conditionals

Checks for unnecessary conditional expressions.

added in: 1.6.0
warning
🛠
preset: recommended
avoid-unnecessary-futures

Warns when a return type of a declaration is unnecessary wrapped into a Future.

added in: 1.7.0
warning
🛠
preset: recommended
avoid-unnecessary-getter

Warns when a getter provides access to an existing final field without any additional logic.

added in: 1.10.0
style
avoid-unnecessary-if

Warns when a return statement inside an if block is equal to the return statement after it.

added in: 1.9.0
warning
🛠
preset: recommended
avoid-unnecessary-local-late

Warns when a late variable is assigned in all code branches before use.

added in: 1.10.0
warning
🛠
preset: recommended
avoid-unnecessary-negations

Warns when a negation can be simplified.

added in: 1.4.0
warning
🛠
preset: recommended
avoid-unnecessary-nullable-return-type

Warns when the return type of a function or a method is declared nullable, but the function or method always return non-nullable value.

added in: 1.0.0
warning
🛠
preset: recommended
avoid-unnecessary-reassignment

Warns when a value is reassigned to a variable without using the initial value.

added in: 1.8.0
warning
preset: recommended
avoid-unnecessary-return

Warns when a return statement is unnecessary and can be removed.

added in: 1.6.0
style
🛠
preset: recommended
avoid-unnecessary-super

Warns when a constructor has an unnecessary super invocation.

added in: 1.11.0
style
preset: recommended
avoid-unnecessary-type-assertions

Warns about unnecessary usage of is and whereType operators.

added in: 1.6.0
warning
preset: recommended
avoid-unnecessary-type-casts

Warns about unnecessary usage of as operators.

added in: 1.6.0
warning
preset: recommended
avoid-unrelated-type-assertions

Warns about unrelated usages of is operators.

added in: 1.6.0
warning
⚙️
preset: recommended
avoid-unrelated-type-casts

Warns about unrelated usages of as operator.

added in: 1.0.0
warning
preset: recommended
avoid-unsafe-collection-methods

Warns when first, last, single, firstWhere, lastWhere, singleWhere or [] methods are used on Iterable or its subclasses.

added in: 1.4.0
warning
🛠
preset: recommended
avoid-unused-after-null-check

Warns when a variable is checked for non-nullable value, but is not used within the condition or then branch.

added in: 1.13.0
warning
avoid-unused-generics

Warns when a function or method declares unused generic types.

added in: 1.4.0
warning
🛠
preset: recommended
avoid-unused-instances

Warns when a newly created object is not being used.

added in: 1.8.0
warning
⚙️
preset: recommended
avoid-unused-parameters

Checks for unused parameters inside a function or method body.

added in: 1.6.0
warning
⚙️🛠
preset: recommended
avoid-weak-cryptographic-algorithms

Warns when a weak cryptographic algorithm (ex. md5 or sha1) is used.

added in: 1.9.0
warning
avoid-wildcard-cases-with-enums

Warns when a switch on the Enum value has a wildcard pattern case.

added in: 1.10.0
warning
preset: recommended
ban-name

Configure names that you want to ban.

added in: 1.6.0
warning
⚙️⚠️
banned-usage

Configure usages that you want to ban.

added in: 1.3.0
warning
⚙️
binary-expression-operand-order

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

added in: 1.6.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
⚙️🛠
enum-constants-ordering

Ensures consistent alphabetical order of Enum constants.

added in: 1.8.0
style
🛠
format-comment

Suggests to format comments like sentences.

added in: 1.6.0
style
⚙️🛠
format-test-name

Warns when a test or testWidgets name doesn't follow the configured pattern.

added in: 1.0.0
style
⚙️
function-always-returns-null

Warns when a function with nullable return type returns only nullvalue.

added in: 1.4.0
warning
⚙️
preset: recommended
map-keys-ordering

Ensures consistent alphabetical order of String keys inside a map.

added in: 1.7.0
style
match-class-name-pattern

Configure class names to match the given pattern.

added in: 1.8.0
style
⚙️
match-getter-setter-field-names

Warns when a getter or setter do not access at least one field with the name that matches the getter or setter name.

added in: 1.10.0
warning
preset: recommended
match-lib-folder-structure

Warns when the file path in the test folder does not match the implementation file path in the lib folder.

added in: 1.11.0
warning
match-positional-field-names-on-assignment

Warns when a positional field name does not match a variable name on destructuring assignment.

added in: 1.5.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: 1.6.0
warning
⚙️
move-records-to-typedefs

Warns when a record type should be moved to a typedef.

added in: 1.5.0
warning
⚙️🛠
move-variable-closer-to-its-usage

Warns when a variable is declared in the outer block, but used only in the inner one.

added in: 1.9.0
warning
preset: recommended
move-variable-outside-iteration

Warns when a variable does not depend on the outer loop and can be moved out.

added in: 1.13.0
warning
🛠
newline-before-case

Enforces a blank line between cases in a switch statement.

added in: 1.8.0
style
🛠
newline-before-return

Enforces a blank line between statements and return in a block.

added in: 1.5.0
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.6.0
style
preset: recommended
no-equal-arguments

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

added in: 1.6.0
warning
⚙️
no-equal-conditions

Warns when a if statement has duplicate conditions.

added in: 1.1.0
warning
preset: recommended
no-equal-nested-conditions

Warns when an if statement contains another if statement with the same condition.

added in: 1.7.0
warning
preset: recommended
no-equal-switch-case

Warns when a switch has cases with equal bodies.

added in: 1.1.0
warning
preset: recommended
no-equal-switch-expression-cases

Warns when a switch expression has cases with equal bodies.

added in: 1.5.0
warning
preset: recommended
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.6.0
warning
🛠
preset: recommended
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.6.0
style
parameters-ordering

Ensures consistent alphabetical order of parameters by their names.

added in: 1.9.0
style
⚙️🛠
prefer-addition-subtraction-assignments

Warns when ++ or -- is used instead of += or -=.

added in: 1.11.0
warning
🛠
prefer-any-or-every

Warns when a collection's call chain can be rewritten to use .any() or .every() instead of .isEmpty or .isNotEmpty.

added in: 1.12.0
warning
🛠
preset: recommended
prefer-async-await

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

added in: 1.6.0
style
prefer-both-inlining-annotations

Warns when a @pragma('vm:prefer-inline') annotation does not have a corresponding @pragma('dart2js:tryInline') annotation.

added in: 1.11.0
warning
🛠
prefer-bytes-builder

Warns when an expensive byte list operation is used.

added in: 1.3.0
warning
prefer-commenting-analyzer-ignores

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

added in: 1.6.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.6.0
style
⚙️🛠
prefer-correct-callback-field-name

Warns when a field with a Function type does not matched the configured name or a field with a non-Function type matches the configured name.

added in: 1.11.0
style
⚙️
preset: recommended
prefer-correct-error-name

Ensures a consistent name for the error parameter in catch, then, catchError, listen and handleError.

added in: 1.7.0
style
⚙️🛠
prefer-correct-for-loop-increment

Warns when a for loop increments a wrong variable.

added in: 1.8.0
warning
preset: recommended
prefer-correct-future-return-type

Warns when a declaration that returns a Future has an incorrect return type.

added in: 1.7.0
warning
🛠
prefer-correct-handler-name

Warns when the callback handler name does not matched the configured one.

added in: 1.11.0
style
⚙️
prefer-correct-identifier-length

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

added in: 1.6.0
style
⚙️
prefer-correct-json-casts

Warns when a JSON object type cast is done in an unsafe way that will throw at runtime.

added in: 1.8.0
style
preset: recommended
prefer-correct-setter-parameter-name

Warns when the setter parameter name does not match the configured one.

added in: 1.11.0
style
⚙️
prefer-correct-stream-return-type

Warns when a declaration that returns a Stream has an incorrect return type.

added in: 1.7.0
warning
🛠
prefer-correct-switch-length

Warns when a switch has too few or too many cases.

added in: 1.3.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: 1.6.0
warning
preset: recommended
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: 1.6.0
style
⚙️
prefer-declaring-const-constructor

Warns when a class with no non-final fields has a non-constant constructor declaration.

added in: 1.0.0
performance
⚙️🛠
preset: recommended
prefer-early-return

Warns when an if statement can be transformed to an early return.

added in: 1.3.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: 1.6.0
style
prefer-explicit-function-type

Warns when a Function type does not specify the return type and arguments.

added in: 1.11.0
warning
preset: recommended
prefer-explicit-parameter-names

Warns when parameter names in function types are omitted.

added in: 1.3.0
style
prefer-explicit-type-arguments

Warns when a method that accepts type arguments has no arguments and no type arguments passed.

added in: 1.11.0
warning
🛠
prefer-first

Use first to gets the first element.

added in: 1.6.0
style
🛠
prefer-getter-over-method

Suggests to convert a method that has no parameters and side-effects to a getter.

added in: 1.9.0
style
prefer-immediate-return

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

added in: 1.6.0
style
🛠
prefer-iterable-of

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

added in: 1.6.0
warning
🛠
preset: recommended
prefer-last

Use last to gets the last element.

added in: 1.6.0
style
🛠
prefer-match-file-name

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

added in: 1.6.0
warning
🛠
preset: recommended
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: 1.6.0
warning
⚙️🛠
prefer-named-boolean-parameters

Warns when a declaration has a boolean positional parameter.

added in: 1.8.0
style
⚙️
prefer-named-imports

Warns if the configured import is not a named import.

added in: 1.10.0
warning
⚙️
prefer-null-aware-spread

Warns when a null check inside a collection literal can be replaced with a null-aware spread (...?).

added in: 1.11.0
style
preset: recommended
prefer-overriding-parent-equality

Warns when a parent class implements hashCode and ==, but the child class does not implement them.

added in: 1.15.0
warning
prefer-parentheses-with-if-null

Warns when an if null (??) has a binary expression without parentheses.

added in: 1.7.0
warning
🛠
preset: recommended
prefer-prefixed-global-constants

Warns when a global constant does not start with a configured prefix.

added in: 1.11.0
style
⚙️
preset: recommended
prefer-private-extension-type-field

Warns when an extension type has a public representation field.

added in: 1.15.0
warning
🛠
prefer-public-exception-classes

Warns when an exception class declaration is not public.

added in: 1.8.0
warning
preset: recommended
prefer-return-await

Warns when a Future is returned from a try / catch block without an await.

added in: 1.2.0
warning
🛠
preset: recommended
prefer-returning-conditional-expressions

Warns when several returns inside a function body can be replace with a single conditional expression.

added in: 1.5.0
style
🛠
prefer-simpler-patterns-null-check

Warns when a patterns check for non-nullability can be simplified.

added in: 1.5.0
warning
🛠
preset: recommended
prefer-specific-cases-first

Warns when a more specific switch case is placed after a more general one.

added in: 1.11.0
warning
🛠
preset: recommended
prefer-static-class

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

added in: 1.6.0
style
⚙️
prefer-switch-with-enums

Suggests to use a switch statement or expression instead of conditionals with multiple enum values.

added in: 1.12.0
style
⚙️
preset: recommended
prefer-test-matchers

Warns when the second argument of an expect or expectLater is not a subclass of a Matcher.

added in: 1.6.0
warning
prefer-trailing-comma

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

added in: 1.6.0
style
⚙️🛠
preset: recommended
prefer-type-over-var

Warns when a variable is declared with the var keyword instead of a type.

added in: 1.7.0
style
🛠
prefer-typedefs-for-callbacks

Warns when a Function type is declared not as a typedef.

added in: 1.11.0
style
⚙️
prefer-unique-test-names

Warns when the test name is not unique within the same test suite.

added in: 1.11.0
warning
⚙️
preset: recommended
prefer-unwrapping-future-or

Warns when a FutureOr is not unwrapped before being used.

added in: 1.4.0
warning
prefer-visible-for-testing-on-members

Warns when the @visibleForTesting annotation is applied to the class declaration.

added in: 1.4.0
warning
🛠
prefer-wildcard-pattern

Warns when a dynamic or Object type is used instead of a wildcard pattern.

added in: 1.5.0
warning
🛠
preset: recommended
tag-name

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

added in: 1.6.0
warning
⚙️🛠
unnecessary-trailing-comma

Checks for unnecessary trailing commas for arguments, parameters, enum values and collections.

added in: 1.2.0
style
⚙️🛠
preset: recommended

Flutter 38 rules

add-copy-with

Warns when a class that matches the config does not declare a copyWith method.

added in: 1.2.0
warning
⚙️
always-remove-listener

Warns when an event listener is added but never removed.

added in: 1.6.0
warning
preset: recommended
avoid-border-all

Warns when Border.all constructor is being used.

added in: 1.6.0
performance
🛠
avoid-empty-setstate

Warns when a setState callback is empty.

added in: 1.3.0
warning
preset: recommended
avoid-expanded-as-spacer

Avoid using Expanded widget as Spacer.

added in: 1.6.0
warning
🛠
avoid-incomplete-copy-with

Checks if all the parameters from the default constructor are included in the copyWith method.

added in: 1.1.0
warning
preset: recommended
avoid-inherited-widget-in-initstate

Warns when context.dependOnInheritedWidgetOfExactType is transitively called from any invocation in initState.

added in: 1.4.0
warning
avoid-late-context

Warns when the context is used inside a late field initializer.

added in: 1.4.0
warning
avoid-missing-controller

Warns when a TextFormField, TextField or EditableText does not have at least one way to get the updated value.

added in: 1.15.0
warning
avoid-missing-image-alt

Warns when an Image widget does not have a semanticLabel.

added in: 1.7.0
warning
⚙️
preset: recommended
avoid-recursive-widget-calls

Warns when a Widget recursively uses itself.

added in: 1.8.0
warning
preset: recommended
avoid-returning-widgets

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

added in: 1.6.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: 1.6.0
performance
avoid-single-child-column-or-row

Warns when a Column, Row, Flex, Wrap, SliverList, SliverMainAxisGroup or SliverCrossAxisGroup widget has only one child.

added in: 1.10.0
warning
avoid-state-constructors

Warns when a State has a constructor with non-empty body.

added in: 1.4.0
warning
preset: recommended
avoid-undisposed-instances

Warns when an instance that has a dispose method is not assigned to a variable.

added in: 1.13.0
warning
⚙️
preset: recommended
avoid-unnecessary-gesture-detector

Warns when a GestureDetector widget has no event handlers.

added in: 1.15.0
warning
avoid-stateless-widget-initialized-fields

Warns when a StatelessWidget has an initialized final field.

added in: 1.5.0
warning
avoid-unnecessary-overrides-in-state

Warns when a widget's State has unnecessary overrides.

added in: 1.7.0
warning
🛠
preset: recommended
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: 1.6.0
warning
preset: recommended
avoid-unnecessary-stateful-widgets

Warns when a StatefulWidget can be converted to a StatelessWidget.

added in: 1.4.0
warning
preset: recommended
avoid-wrapping-in-padding

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

added in: 1.6.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: 1.6.0
warning
preset: recommended
consistent-update-render-object

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

added in: 1.6.0
warning
preset: recommended
dispose-fields

Warns when a widget state field is not disposed in dispose method.

added in: 1.3.0
warning
⚙️
preset: recommended
prefer-action-button-tooltip

Warns when a FloatingActionButton does not have a tooltip specified.

added in: 1.4.0
warning
🛠
prefer-const-border-radius

Warns when a non-const border radius is used.

added in: 1.6.0
performance
🛠
prefer-correct-edge-insets-constructor

Suggests using the correct EdgeInsets constructor.

added in: 1.6.0
style
🛠
prefer-dedicated-media-query-methods

Warns when MediaQuery.of or MediaQuery.maybeOf are used over dedicated methods (ex. sizeOf).

added in: 1.7.0
warning
preset: recommended
prefer-define-hero-tag

Warns when a Widget has an unset heroTag.

added in: 1.6.0
warning
🛠
prefer-extracting-callbacks

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

added in: 1.6.0
style
⚙️
prefer-single-widget-per-file

Warns when a file contains more than one widget.

added in: 1.6.0
style
⚙️
preset: recommended
prefer-sliver-prefix

Warns when a widget that returns a Sliver... widget does not have a Sliver prefix in its name.

added in: 1.10.0
style
prefer-text-rich

Warns when a RichText widget is used instead of Text.rich.

added in: 1.8.0
warning
🛠
prefer-using-list-view

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

added in: 1.6.0
performance
prefer-widget-private-members

Warns when a widget or widget state have public members (fields, methods, etc.).

added in: 1.3.0
style
🛠
proper-super-calls

Checks that super calls in the initState and dispose methods are called in the correct order.

added in: 1.2.0
warning
🛠
preset: recommended
use-setstate-synchronously

Warns when setState is called past an await point.

added in: 1.6.0
warning
⚙️
preset: recommended

Provider 5 rules

note
Lint rules for the Provider package.
avoid-instantiating-in-value-provider

Warns when a Provider.value returns a new instance instead of reusing an existing one.

added in: 1.4.0
warning
avoid-read-inside-build

Warns when a read method is used inside of the build method.

added in: 1.4.0
warning
avoid-watch-outside-build

Warns when a watch or select methods are used outside of the build method.

added in: 1.4.0
warning
dispose-providers

Warns when a provided class with a dispose method does not have this method called in the Provider dispose callback.

added in: 1.4.0
warning
prefer-multi-provider

Warns when multiple nested Providers can be replaced with MultiProvider instead.

added in: 1.4.0
warning

Bloc 6 rules

note
Lint rules for the Bloc package.
avoid-bloc-public-methods

Warns when a Bloc has public methods except the overridden ones.

added in: 1.2.0
warning
🛠
avoid-cubits

Warns when a Cubit is used.

added in: 1.2.0
warning
avoid-passing-bloc-to-bloc

Warns when a Bloc depends on another Bloc.

added in: 1.2.0
warning
check-is-not-closed-after-async-gap

Warns when an async handler does not have isClosed check before dispatching an event after an async gap.

added in: 1.4.0
warning
prefer-correct-bloc-provider

Warns when a Bloc is provided not with a BlocProvider.

added in: 1.2.0
warning
🛠
prefer-multi-bloc-provider

Warns when a BlocProvider / BlocListener / RepositoryProvider can be replace with a Multi version.

added in: 1.2.0
performance

Equatable 2 rules

note
Lint rules for the Equatable package.
extend-equatable

Warns when a class that matches the config does not extend Equatable.

added in: 1.2.0
warning
⚙️
list-all-equatable-fields

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

added in: 1.2.0
warning
🛠

Flame 4 rules

note
Lint rules for the Flame package.
avoid-creating-vector-in-update

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

added in: 1.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: 1.6.0
warning
avoid-redundant-async-on-load

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

added in: 1.6.0
warning
🛠
correct-game-instantiating

Warns when a game is instantiated in a StatelessWidget build method.

added in: 1.6.0
warning
🛠

Patrol 2 rules

note
Lint rules for the Patrol package.
prefer-custom-finder-over-find

Suggests using custom finders instead of find in Patrol tests.

added in: 1.8.0
style
prefer-symbol-over-key

Suggests using symbols instead of string keys in Patrol tests.

added in: 1.8.0
style

Fake Async 1 rule

note
Lint rules for the Fake Async package.
avoid-async-callback-in-fake-async

Warns when an async callback is passed to FakeAsync.

added in: 1.9.0
warning
🛠

Get It 1 rule

note
Lint rules for the Get It package.
avoid-functions-in-register-singleton

Warns when a function is passed to registerSingleton.

added in: 1.10.0
warning

Flutter Hooks 3 rules

note
avoid-conditional-hooks

Warns when hooks inside the build method or other hooks are called conditionally.

added in: 1.12.0
warning
avoid-hooks-outside-build

Warns when a hook is used outside the build method, other hooks or HookBuilder.

added in: 1.12.0
warning
prefer-use-prefix

Suggests renaming hooks to start with use.

added in: 1.12.0
style

Pubspec 8 rules

caution
Pub rules should be added to the pubspec-rules: config section.
avoid-any-version

Warns when a dependency version is set as any.

added in: 1.2.0
warning
avoid-dependency-overrides

Warns when a pubspec file has the dependency_overrides section.

added in: 1.2.0
warning
banned-dependencies

Warns when a pubspec contains a banned dependency.

added in: 1.2.0
warning
⚙️
prefer-caret-version-syntax

Warns when a dependency version is listed not with the caret syntax.

added in: 1.2.0
warning
prefer-correct-package-name

Warns when a package name does not match the config.

added in: 1.2.0
warning
⚙️
prefer-correct-screenshots

Warns when a screenshots section has incorrect entries.

added in: 1.2.0
warning
prefer-publish-to-none

Warns when a pubspec file does not have publish_to: none config.

added in: 1.2.0
warning
prefer-semver-version

Warns when a package version does not match the semantic versioning approach.

added in: 1.2.0
warning

Intl 6 rules

note
Lint rules for the Intl package.
prefer-date-format

Warns when DateTime, values are formatted with toString instead of DateFormat.format().

added in: 1.7.0
warning
🛠
prefer-intl-name

Recommends to use ClassName_ClassMemberName pattern for Intl methods name argument.

added in: 1.6.0
style
🛠
prefer-number-format

Warns when int, num or double values are formatted with toString instead of NumberFormat.format().

added in: 1.6.0
warning
🛠
prefer-providing-intl-description

Warns when an Intl method invoked without a description.

added in: 1.6.0
warning
prefer-providing-intl-examples

Warns when an Intl method invoked without an examples argument or has it incomplete.

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

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

added in: 1.6.0
warning

Angular 3 rules

avoid-preserve-whitespace-false

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

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

Enforces Angular @Component annotation arguments ordering.

added in: 1.6.0
style
⚙️
prefer-on-push-cd-strategy

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

added in: 1.6.0
warning
No rules found with provided filter criteria.