I wanted to have a EnumClass
with an optional message
field, something like this:
class Status extends EnumClass {
static const Status error = _$error;
static const Status completed = _$completed;
String message;
const Status._(String name) : super(name);
static BuiltSet<Status> get values => _$values;
static Status valueOf(String name) => _$valueOf(name);
}
The problem is I get this error message:
Can't define a const constructor for a class with non-final fields.
And if I declare message
as final
, then I can't initialize it, since the constructor is hidden.
Is there a way to achieve this? Maybe make a generated Enum Builder?