illegal_ concrete_ enum_ member
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;
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 {
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 {
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 {
bool operator ==(Object other) => false;
}
Common fixes
#Rename the conflicting member:
enum E {
v;
int get getIndex => 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.