Tsallaka zuwa abun ciki
Justice Tech School

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

What does values give?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.