Dart Analyze

Dart Analyze

Community Analyzer
Don't put any logic in createState DRT-W1023
Bug risk
Major

DON'T put any logic in createState(). Implementations of createState() should return a new instance

Don't assign a variable to itself DRT-W1024
Bug risk
Major

DON'T assign a variable to itself. Usually this is a mistake. BAD:

Don't use wildcard parameters or variables DRT-W1025
Bug risk
Major

DON'T use wildcard parameters or variables. Wildcard parameters and local variables

Don't use the Null type, unless you are positive that you don't want void DRT-W1027
Bug risk
Major

DON'T use the type Null where void would work. BAD:

Avoid unnecessary containers DRT-W1072
Anti-pattern
Major

AVOID wrapping widgets in unnecessary containers. Wrapping a widget in Container with no other parameters set has no effect

Avoid empty else statements DRT-W1003
Bug risk
Major

AVOID empty else statements. BAD:

Avoid final for parameter declarations DRT-W1054
Anti-pattern
Major

AVOID declaring parameters as final. Declaring parameters as final can lead to unnecessarily verbose code, especially

Sort combinator names alphabetically DRT-W1080
Anti-pattern
Major

DO sort combinator names alphabetically. BAD:

Avoid print calls in production code DRT-W1004
Bug risk
Major

DO avoid print calls in production code. For production code, consider using a logging framework.

Don't use more than one case with same value DRT-W1022
Bug risk
Major

DON'T use more than one case with same value. This is usually a typo or changed value of constant.

Sort pub dependencies alphabetically DRT-W1039
Anti-pattern
Major

DO sort pub dependencies alphabetically (A to Z) in pubspec.yaml. Sorting list of pub dependencies makes maintenance easier.

Avoid bool literals in conditional expressions DRT-W1046
Anti-pattern
Major

AVOID bool literals in conditional expressions. BAD:

Avoid shadowing type parameters DRT-W1069
Anti-pattern
Major

AVOID shadowing type parameters. BAD:

Prefer using lowerCamelCase for constant names DRT-W1082
Anti-pattern
Major

PREFER using lowerCamelCase for constant names. In new code, use lowerCamelCase for constant variables, including enum values.

Attach library doc comments to library directives DRT-W1084
Anti-pattern
Major

Attach library doc comments (with ///) to library directives, rather than leaving them dangling near the top of a library.

Deprecated member used in the same package DRT-W1015
Bug risk
Major

The analyzer produces this diagnostic when a deprecated library member or class member is used in the same package in which it's declared.

Prefer relative imports for files in lib/ DRT-W1026
Bug risk
Major

PREFER relative imports for files in lib/. When mixing relative and absolute imports it's possible to create confusion

Avoid relative imports for files in lib/ DRT-W1001
Bug risk
Major

DO avoid relative imports for files in lib/. When mixing relative and absolute imports it's possible to create confusion