Dart Analyze logoDart Analyze/
DRT-W1382

Invalid declaration of 'values' in a class that implements 'Enum'DRT-W1382

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when either a class that implements Enum or a mixin with a superclass constraint of Enum has an instance member named values.

Examples

The following code produces this diagnostic because the class C, which implements Enum, declares an instance field named values:

abstract class C implements Enum {
  int get values => 0;
}

The following code produces this diagnostic because the class B, which implements Enum, inherits an instance method named values from A:

abstract class A {
  int values() => 0;
}

abstract class B extends A implements Enum {}

Common fixes

Change the name of the conflicting member:

abstract class C implements Enum {
  int get value => 0;
}