-
Notifications
You must be signed in to change notification settings - Fork 219
Open
Labels
enhanced-constRequests or proposals about enhanced constant expressionsRequests or proposals about enhanced constant expressionssmall-featureA small feature which is relatively cheap to implement.A small feature which is relatively cheap to implement.
Description
I have noticed that dart won't accept the argument of enums as const value, although both enums and their arguments are exclusively const.
This really sucks when trying to keep the class constant, but just by accessing the definitely constant argument the class won't be accepted as a constant one.
enum Foo {
bar('The answer to life, the universe, and everything.'),
baz('Flutter and dart are awesome.');
const Foo(this.message);
final String message;
}
class Bar {
final Foo foo;
const Bar(this.foo)
: assert(foo == Foo.bar),
assert(foo.message == "Only real messages"); // Will not accept message as const
}
I am using:
- Dart SDK version: 2.19.0-444.4.beta
- Android Studio on MacOSX
devmrcs, gnprice, lucavenir, Reprevise, polarby and 16 moreSoftWyer, guopeng1994 and AhmedLSayed9
Metadata
Metadata
Assignees
Labels
enhanced-constRequests or proposals about enhanced constant expressionsRequests or proposals about enhanced constant expressionssmall-featureA small feature which is relatively cheap to implement.A small feature which is relatively cheap to implement.