Created
April 4, 2019 16:42
-
-
Save aryzhov/0302e718f18e7639f1a0a3a2ea142e5e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Converts an enumeration value to its string representation without the type name | |
enumStr(dynamic enumValue) { | |
return enumValue?.toString()?.split('.')?.last; | |
} | |
// Converts a string to an enum value. Works as the inverse of [enumStr()]. | |
parseEnum(List<dynamic> values, String value) { | |
return value == null ? null : values.firstWhere((v) => enumStr(v) == value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment