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

Missing whitespace between adjacent strings DRT-W1104
Anti-pattern
Major

Add a trailing whitespace to prevent missing whitespace between adjacent strings.

Use interpolation to compose strings and values DRT-W1146
Anti-pattern
Major

PREFER using interpolation to compose strings and values. Using interpolation when composing strings and values is usually easier to write

Unnecessary new keyword DRT-W1182
Anti-pattern
Major

AVOID new keyword to create instances. BAD:

Parameter type mismatch for constant constructor DRT-W1265
Bug risk
Major

The analyzer produces this diagnostic when the runtime type of a constant value can't be assigned to the static type of a constant constructor's parameter.

Remove deprecated key from pubspec.yaml DRT-W1297
Bug risk
Major

The analyzer produces this diagnostic when a key is used in a pubspec.yaml file that was deprecated. Unused keys take up space and might imply semantics that are no longer valid.

The operator x ~/ y is more efficient than (x / y).toInt() DRT-W1302
Bug risk
Major

The analyzer produces this diagnostic when the result of dividing two numbers is converted to an integer using toInt. Dart has a built-in integer division operator that is both more efficient and more concise.

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:

Only throw instances of classes extending either Exception or Error DRT-W1115
Anti-pattern
Major

DO throw only instances of classes that extend dart.core.Error or dart.core.Exception.

Prefer putting asserts in initializer lists DRT-W1121
Anti-pattern
Major

DO put asserts in initializer lists. BAD:

Integer literal exceeds 64-bit representation limit DRT-W1406
Bug risk
Major

The analyzer produces this diagnostic when an integer literal has a value that is too large (positive) or too small (negative) to be represented in a 64-bit word.

Prefer final in for-each loop variable if reference is not reassigned DRT-W1134
Anti-pattern
Major

DO prefer declaring for-each loop variables as final if they are not reassigned later in the code.