Skip to content

Instantly share code, notes, and snippets.

@ailabs-software
Last active June 23, 2020 21:02
Show Gist options
  • Save ailabs-software/c86a46106e99295efe4a57cc6949d833 to your computer and use it in GitHub Desktop.
Save ailabs-software/c86a46106e99295efe4a57cc6949d833 to your computer and use it in GitHub Desktop.
How can I use fields of const-constructed objects in switch cases?
class Property
{
final String foo;
const Property(String this.foo);
}
const Property MARGIN = const Property("margin");
const Property PADDING = const Property("padding");
void main()
{
Property someProperty = MARGIN;
switch(someProperty.foo)
{
case MARGIN.foo:
//doThis();
break;
case PADDING.foo:
//doThis();
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment