values_ declaration_ in_ enum
A member named 'values' can't be declared in an enum.
Description
#
The analyzer produces this diagnostic when an enum declaration defines a
member named
values
, whether the member is an enum value, an instance
member, or a static member.
Any such member conflicts with the implicit declaration of the static
getter named
values
that returns a list containing all the enum
constants.
Example
#
The following code produces this diagnostic because the enum
E
defines
an instance member named
values
:
enum E {
v;
void values() {}
}
Common fixes
#Change the name of the conflicting member:
enum E {
v;
void getValues() {}
}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.