Thuta Learning
Flutter
IntermediateMobile Developmentbeginner

Forms, Validation & Focus

Flutterသင်ခန်းစာ 15

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Forms, Validation & Focus ရဲ့ widget, state နဲ့ lifecycle behavior ကိုရှင်းပြနိုင်ရန်
  • Responsive, failure နဲ့ interaction cases စမ်းနိုင်ရန်
  • Accessible, testable, performant Flutter code ရေးနိုင်ရန်

Forms, Validation & Focus မှာ source of truth, validation, focus, controller disposal နဲ့ minimal rebuild boundary ကိုရှင်းပါ။ Ephemeral state ကို local ထားပြီး shared app state ကို testable controller/model တစ်ခုကပိုင်ဆိုင်စေပါ။

ပိုပြီးနားလည်ထားရမယ့် အချက်

Forms, Validation & Focus မှာ source of truth, validation, focus, controller disposal နဲ့ minimal rebuild boundary ကိုရှင်းပါ။ Ephemeral state ကို local ထားပြီး shared app state ကို testable controller/model တစ်ခုကပိုင်ဆိုင်စေပါ။

လက်တွေ့မှာ ဘယ်လိုအသုံးချမလဲ

Forms, Validation & Focus example ကို small/large screen, text scaling, empty/loading/error, rapid interaction, navigation restore နဲ့ disposal cases ဖြင့် run/test လုပ်ပါ။ flutter analyze, widget tests နဲ့ profile mode ကိုလိုအပ်သလိုသုံးပါ။

ဒီသင်ခန်းစာပြီးရင်

dart
final formKey = GlobalKey<FormState>();

Form(
  key: formKey,
  child: Column(children: [
    TextFormField(
      decoration: const InputDecoration(labelText: 'Email'),
      validator: (value) => (value?.contains('@') ?? false) ? null : 'Enter a valid email',
    ),
    FilledButton(
      onPressed: () => formKey.currentState!.validate(),
      child: const Text('Submit'),
    ),
  ]),
)
You should see
Invalid input ဖြစ်လျှင် inline validation message ပေါ်မည်

ကိုယ်တိုင်စမ်းကြည့်ရန်

Forms, Validation & Focus example ကို small/large screen, text scaling, empty/loading/error, rapid interaction, navigation restore နဲ့ disposal cases ဖြင့် run/test လုပ်ပါ။ flutter analyze, widget tests နဲ့ profile mode ကိုလိုအပ်သလိုသုံးပါ။

Lifecycle/Performance သတိပေးချက်

Screen တစ်မျိုးတွင် sample output မှန်ရုံဖြင့် rebuild, overflow, accessibility, async နဲ့ lifecycle paths အားလုံးမှန်ပြီဟုယူဆခြင်း။

Flutter documentationFlutter

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Screen တစ်မျိုးတွင် sample output မှန်ရုံဖြင့် rebuild, overflow, accessibility, async နဲ့ lifecycle paths အားလုံးမှန်ပြီဟုယူဆခြင်း။
  • build() ထဲ expensive work လုပ်ခြင်း၊ controller/subscription မပိတ်ခြင်း သို့ setState ကိုကျယ်သော subtree ပေါ်ခေါ်ခြင်း။

လက်တွေ့လေ့ကျင့်ခန်း

Forms, Validation & Focus example ကို small/large screen, text scaling, empty/loading/error, rapid interaction, navigation restore နဲ့ disposal cases ဖြင့် run/test လုပ်ပါ။ flutter analyze, widget tests နဲ့ profile mode ကိုလိုအပ်သလိုသုံးပါ။

You'll know it worked when: Invalid input ဖြစ်လျှင် inline validation message ပေါ်မည်