Enum Values, index, and name
Iterate and inspect enum members.
Enums Know Their Members
Every enum quietly tracks all of its members for you. Dart gives you built-in ways to list, count, and inspect them.
The values List
Each enum has a static values list holding every member in order. It is your gateway to looping over an enum.
enum Color { red, green, blue }
print(Color.values); // [Color.red, ...]All lessons in this course
- Declaring and Using Plain Enums
- Enum Values, index, and name
- Enhanced Enums With Fields and Methods
- switch Over Enums Exhaustively