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();
}
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.