Enums
Enhanced enums have fields and methods. values lists them and name gives the name.
Example
enum Level {
low(1), high(9);
final int code;
const Level(this.code);
}
void main() {
print(Level.high.code);
print(Level.values.map((l) => l.name).toList());
}Exercise
Enum keyword.
Level { a, b }Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.