Last active
June 6, 2023 04:07
-
-
Save stephanedeluca/4e99d3f578311288842a0ab5e069797e to your computer and use it in GitHub Desktop.
Create an non existant enum in dart
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
/// Shows what to do when creating an enum value from a integer value | |
enum ThemeColor { red, green,} | |
void main() { | |
try { | |
final nonExistent = ThemeColor.values[3]; | |
print("Non existent enum is $nonExistent"); | |
} | |
catch(e) { | |
print("Non existent enum thrown"); | |
} | |
} | |
// Non existent enum thrown |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment