enum_constant_same_name_as_enclosing
The name of the enum value can't be the same as the enum's name.
Description
#The analyzer produces this diagnostic when an enum value has the same name as the enum in which it's declared.
Example
#The following code produces this diagnostic because the enum value E
has the same name as the enclosing enum E
:
dart
enum E {
E
}
Common fixes
#If the name of the enum is correct, then rename the constant:
dart
enum E {
e
}
If the name of the constant is correct, then rename the enum:
dart
enum F {
E
}
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.