Dart Analyze logoDart Analyze/
DRT-W1239

Types can't be assigned a valueDRT-W1239

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when the name of a type name appears on the left-hand side of an assignment expression.

Example

The following code produces this diagnostic because the assignment to the class C is invalid:

class C {}

void f() {
  C = null;
}

Common fixes

If the right-hand side should be assigned to something else, such as a local variable, then change the left-hand side:

void f() {}

void g() {
  var c = null;
  print(c);
}