Dart Analyze logoDart Analyze/
DRT-W1283

Invalid class name specified for instance creationDRT-W1283

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when an instance creation using either new or const specifies a name that isn't defined as a class.

Example

The following code produces this diagnostic because f is a function rather than a class:

int f() => 0;

void g() {
  new f();
}

Common fixes

If a class should be created, then replace the invalid name with the name of a valid class:

int f() => 0;

void g() {
  new Object();
}

If the name is the name of a function and you want that function to be invoked, then remove the new or const keyword:

int f() => 0;

void g() {
  f();
}