illegal_ enum_ values
An instance member named 'values' can't be declared in a class that implements 'Enum'.
An instance member named 'values' can't be inherited from '{0}' in a class that implements 'Enum'.
Description
#
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;
}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.