Dart Analyze logoDart Analyze/
DRT-W1706

A member named 'values' can't be declared in an enumDRT-W1706

Major severityMajor
Bug Risk categoryBug Risk

The analyzer produces this diagnostic when an enum declaration defines a member named values, whether the member is an enum constant, an instance member, or a static member.

Any such member conflicts with the implicit declaration of the static getter named values that returns a list containing all the enum constants.

Example

The following code produces this diagnostic because the enum E defines an instance member named values:

enum E {
  v;
  void values() {}
}

Common fixes

Change the name of the conflicting member:

enum E {
  v;
  void getValues() {}
}