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;
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。