illegal_ enum_ values
Details about the 'illegal_enum_values' diagnostic produced by the Dart analyzer.
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.12.2 版本报告页面问题.