-
Notifications
You must be signed in to change notification settings - Fork 228
Open
Labels
requestRequests to resolve a particular developer problemRequests to resolve a particular developer problem
Description
In one of my projects, I use enhanced enums to create constants. Some of these should work together with one another. And I have a String field that should have the same value between them. Currently, this must be defined on a private constant and used to instantiate the enum constants.
We can't even write asserts to make sure they match because accessing these fields in a const constructor is invalid.
Since, currently, all enhanced enum fields must be constant, we could think of considering all of them potentially constant (I think that would solve the issue), right? So we could do:
enum One {
a('string a'),
b('bbbbb');
const One(this.value);
final String value;
}
enum Two {
a(.a),
b(.b);
const Two(One one) : value = one.value;
final String value;
}Is there a better/another solution? Are there any problems with my suggestion? Thanks!
Metadata
Metadata
Assignees
Labels
requestRequests to resolve a particular developer problemRequests to resolve a particular developer problem