Sealed Types & Error Handling ကို stable API နဲ့ exhaustive domain model ဖော်ပြဖို့သုံးပါ။ Composition, sealed hierarchies, constrained generics နဲ့ focused extensions ကိုဦးစားပေးပြီး hidden mutation နဲ့ unchecked casts ကိုလျှော့ပါ။
ပိုပြီးနားလည်ထားရမယ့် အချက်
Sealed Types & Error Handling ကို stable API နဲ့ exhaustive domain model ဖော်ပြဖို့သုံးပါ။ Composition, sealed hierarchies, constrained generics နဲ့ focused extensions ကိုဦးစားပေးပြီး hidden mutation နဲ့ unchecked casts ကိုလျှော့ပါ။
လက်တွေ့မှာ ဘယ်လိုအသုံးချမလဲ
Sealed Types & Error Handling example ကို null, empty, boundary, invalid, async-error နဲ့ cancellation cases ဖြင့် run/test လုပ်ပါ။ dart format, dart analyze နဲ့ dart test ကိုသုံးပြီး Future/Stream subscription နဲ့ isolate boundary ကိုလိုအပ်သလိုစစ်ပါ။
ဒီသင်ခန်းစာပြီးရင်
sealed class LoadState {}
class Loading extends LoadState {}
class Ready extends LoadState { Ready(this.items); final List<String> items; }
class Failed extends LoadState { Failed(this.message); final String message; }
String label(LoadState state) => switch (state) {
Loading() => 'Loading',
Ready(items: final items) => 'Ready: ${items.length}',
Failed(message: final message) => 'Error: $message',
};
void main() => print(label(Ready(['A', 'B'])));Ready: 2ကိုယ်တိုင်စမ်းကြည့်ရန်
Sealed Types & Error Handling example ကို null, empty, boundary, invalid, async-error နဲ့ cancellation cases ဖြင့် run/test လုပ်ပါ။ dart format, dart analyze နဲ့ dart test ကိုသုံးပြီး Future/Stream subscription နဲ့ isolate boundary ကိုလိုအပ်သလိုစစ်ပါ။
Null/Async သတိပေးချက်
Sample output တစ်ခုမှန်ရုံဖြင့် null, promotion, Future, Stream နဲ့ isolate paths အားလုံးမှန်ပြီဟုယူဆခြင်း။
Dart class modifiers — Dart