Python Enhanced Enums with Fields, Methods & Patterns
In modern Dart, **Enhanced Enums** behave like full-fledged immutable classes. Enums can declare final fields, custom `const` constructors, getters, methods, and implement interfaces. Combined with Dart 3 switch expressions, enhanced enums provide exhaustive, bulletproof state representations.
"Enhanced enums are like official military ranks: not only is each rank distinct in name (Captain, Major, General), but each rank comes with specific assigned salary grades, authority levels, and insignia."
Deep Dive: How It Works
Fields and Constructors: `enum Status { ok(200), err(500); final int code; const Status(this.code); }`.
Instance Methods: Enums can declare methods and computed properties.
Values List: `EnumName.values` provides an unmodifiable list of all declared enum variants.
Syntax Blueprint
enum Priority {
low(1), medium(2), high(3);
final int level;
const Priority(this.level);
bool get isUrgent => level >= 3;
}Enhanced enum with fields, const constructor, and computed getter.
Core Rules to Remember



Common Beginner Traps & How to Fix Them
Attempting to add non-final fields to an enum.Why it happens: Enum members are compile-time constants and must remain deeply immutable.
How to fix: Ensure all enum fields are declared `final`.
Live Interactive Example
Hit Run Code to see it liveYour Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Define Plan Tier Enhanced Enum
Create `enum Plan { free(0), pro(29); final int price; const Plan(this.price); }`.
In `main()`, print `Pro Plan: $${Plan.pro.price}/mo`.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.