Dart Analyze logoDart Analyze/
DRT-W1324

The invoked constructor isn't a 'const' constructorDRT-W1324

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when an enum constant is being created using either a factory constructor or a generative constructor that isn't marked as being const.

Example

The following code produces this diagnostic because the enum constant e is being initialized by a factory constructor:

enum E {
  e();

  factory E() => e;
}

Common fixes

Use a generative constructor marked as const:

enum E {
  e._();

  factory E() => e;

  const E._();
}