non_const_generative_enum_constructor
Generative enum constructors must be 'const'.
Description
#The analyzer produces this diagnostic when an enum declaration contains a
generative constructor that isn't marked as const
.
Example
#The following code produces this diagnostic because the constructor in E
isn't marked as being const
:
dart
enum E {
e;
E();
}
Common fixes
#Add the const
keyword before the constructor:
dart
enum E {
e;
const E();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。