Last active
June 23, 2020 21:02
-
-
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?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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