Enums and Records
Enhanced enums have fields and methods. Records group values without a class, and patterns destructure them.
Example
enum Level { beginner(1), advanced(3); final int weight; const Level(this.weight); }
void main() {
var p = (name: "Ada", age: 21);
var (n, a) = (1, 2);
print("${p.name} ${Level.advanced.weight} $n $a");
}Exercise
Declare an enum.
Color { red }Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.