enum_constant_with_non_const_constructor
The invoked constructor isn't a 'const' constructor.
Description
#The analyzer produces this diagnostic when an enum value is being created
using either a factory constructor or a generative constructor that isn't
marked as being const
.
Example
#The following code produces this diagnostic because the enum value e
is
being initialized by a factory constructor:
dart
enum E {
e();
factory E() => e;
}
Common fixes
#Use a generative constructor marked as const
:
dart
enum E {
e._();
factory E() => e;
const E._();
}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。