illegal_ concrete_ enum_ member
Details about the 'illegal_concrete_enum_member' diagnostic produced by the Dart analyzer.
A concrete instance member named '{0}' can't be declared in a class that implements 'Enum'.
A concrete instance member named '{0}' can't be inherited from '{1}' in a class that implements 'Enum'.
Description
#
The analyzer produces this diagnostic when either an enum
declaration, a class that implements Enum, or a
mixin with a superclass constraint of Enum,
declares or inherits a concrete instance member named either
index, hashCode, or ==.
Examples
#
The following code produces this diagnostic because the enum
E declares an instance getter named
index:
enum E {
v;
@override
int get index => 0;
}
The following code produces this diagnostic because the class
C, which implements Enum, declares
an instance field named hashCode:
abstract class C implements Enum {
@override
int hashCode = 0;
}
The following code produces this diagnostic because the class
C, which indirectly implements
Enum through the class A, declares
an instance getter named hashCode:
abstract class A implements Enum {}
abstract class C implements A {
@override
int get hashCode => 0;
}
The following code produces this diagnostic because the mixin
M, which has Enum in the
on clause, declares an explicit operator named
==:
mixin M on Enum {
@override
bool operator ==(Object other) => false;
}
Common fixes
#Rename the conflicting member:
enum E {
v;
int get getIndex => 0;
}
除非另有说明,文档之所提及适用于 Dart 3.12.2 版本报告页面问题.