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
:
dart
enum E {
v;
void values() {}
}
Common fixes
#Change the name of the conflicting member:
dart
enum E {
v;
void getValues() {}
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。