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 empty else statements DRT-W1003
Bug risk
Major

AVOID empty else statements. 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.

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

Avoid slow async dart:io methods DRT-W1006
Bug risk
Major

AVOID using the following asynchronous file I/O methods because they are much slower than their synchronous counterparts.

Avoid <Type>.toString() in production code since results may be minified DRT-W1007
Bug risk
Major

DO avoid calls to .toString() in production code, since it does not contractually return the user-defined name of the Type (or underlying class). Development-mode compilers where code size is not a concern use the full name,

Avoid types as parameter names DRT-W1008
Bug risk
Major

AVOID using a parameter name that is the same as an existing type. BAD:

Avoid using web-only libraries outside Flutter web plugin packages DRT-W1009
Bug risk
Major

AVOID using web libraries, dart:html, dart:js and dart:js_util in Flutter packages that are not web plugins. These libraries are not supported outside a web context; functionality that depends on them will

Cancel instances of dart.async.StreamSubscription DRT-W1010
Bug risk
Major

DO invoke cancel on instances of dart.async.StreamSubscription. Cancelling instances of StreamSubscription prevents memory leaks and unexpected

Close instances of dart.core.Sink DRT-W1011
Bug risk
Major

DO invoke close on instances of dart.core.Sink. Closing instances of Sink prevents memory leaks and unexpected behavior.

Only reference in scope identifiers in doc comments DRT-W1013
Bug risk
Major

DO reference only in scope identifiers in doc comments. If you surround things like variable, method, or type names in square brackets,

Avoid control flow in finally blocks DRT-W1014
Bug risk
Major

AVOID control flow leaving finally blocks. Using control flow in finally blocks will inevitably cause unexpected behavior

DO reference all public properties in debug methods DRT-W1016
Bug risk
Major

DO reference all public properties in debug method implementations. Implementers of Diagnosticable should reference all public properties in

Don't invoke asynchronous functions in non-async blocks DRT-W1017
Bug risk
Major

Making asynchronous calls in non-async functions is usually the sign of a programming error. In general these functions should be marked async and such futures should likely be awaited (as enforced by unawaited_futures).