ရိုးရိုးလေး ရှင်းပြမယ်
What are Widgets? ကို ရိုးရိုးလေးနားလည်မယ်
Flutter မှာ widget ဆိုတာ UI ကိုဖော်ပြတဲ့ building block ပါ။ Button တစ်ခု၊ စာသားတစ်ကြောင်း၊ padding တစ်ခု၊ layout တစ်ခု၊ screen တစ်ခုလုံး — အားလုံးက widget တွေပဲဖြစ်ပါတယ်။ Widget ကို object လို့မမြင်ဘဲ screen ပေါ်မှာ ဘာပုံစံပေါ်မလဲဆိုတဲ့ instruction card လို့မြင်ပါ။ Flutter app တစ်ခုကို widget tree အဖြစ်ဖွဲ့စည်းထားပါတယ်။ Parent widget က child widget ကိုကိုင်ထားပြီး child widget က နောက်ထပ် child တွေကိုဆက်ကိုင်နိုင်ပါတယ်။ ဒီ tree ကိုနားလည်ရင် layout, styling, state update တို့ကို ပိုမြန်မြန်နားလည်လာပါမယ်။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
UI တစ်ခုလုံးကို Container တစ်ခုထဲမှာအကုန်စုပြီးရေးတာက code ကိုဖတ်ရခက်စေပါတယ်။ Widget တွေကို တာဝန်အလိုက်ခွဲရေးပါ။
ဖြစ်လေ့ရှိတဲ့အမှား
Screen တစ်မျိုးတွင် sample output မှန်ရုံဖြင့် rebuild, overflow, accessibility, async နဲ့ lifecycle paths အားလုံးမှန်ပြီဟုယူဆခြင်း။
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
What are Widgets? ကို widget syntax အဖြစ်သာမမြင်ဘဲ constraints, size, position, rebuild scope, semantics နဲ့ platform adaptation contract အဖြစ်နားလည်ပါ။ Widget tree ကိုသေးသေးခွဲပြီး const widgets, lazy builders နဲ့ responsive constraints ကိုဦးစားပေးပါ။
- Input + state
- Widget build + layout
- Rendered Flutter UI
What are Widgets? ရဲ့ widget, state နဲ့ lifecycle behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
Scaffold(
appBar: AppBar(
title: const Text('Widget Tree'),
),
body: const Center(
child: Text('Every UI piece is a widget'),
),
)What are Widgets? ကို widget syntax အဖြစ်သာမမြင်ဘဲ constraints, size, position, rebuild scope, semantics နဲ့ platform adaptation contract အဖြစ်နားလည်ပါ။ Widget tree ကိုသေးသေးခွဲပြီး const widgets, lazy builders နဲ့ responsive constraints ကိုဦးစားပေးပါ။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- Input + state
Scaffold(Flutter မှာ widget ဆိုတာ UI ကိုဖော်ပြတဲ့ building block ပါ။ Button တစ်ခု၊ စာသားတစ်ကြောင်း၊ padding တစ်ခု၊ layout တစ်ခု၊ screen တစ်ခုလုံး — အားလုံးက widget တွေပဲဖြစ်ပါတယ်။ Widget ကို object လို့မမြင်ဘဲ screen ပေါ်မှာ ဘာပုံစံပေါ်မလဲဆိုတဲ့ instruction card လို့မြင်ပါ။ Flutter app တစ်ခုကို widget tree အဖြစ်ဖွဲ့စည်းထားပါတယ်။ Parent widget က child widget ကိုကိုင်ထားပြီး child widget က နောက်ထပ် child တွေကိုဆက်ကိုင်နိုင်ပါတယ်။ ဒီ tree ကိုနားလည်ရင် layout, styling, state update တို့ကို ပိုမြန်မြန်နားလည်လာပါမယ်။
- Widget build + layout
body: const Center(What are Widgets? ကို widget syntax အဖြစ်သာမမြင်ဘဲ constraints, size, position, rebuild scope, semantics နဲ့ platform adaptation contract အဖြစ်နားလည်ပါ။ Widget tree ကိုသေးသေးခွဲပြီး const widgets, lazy builders နဲ့ responsive constraints ကိုဦးစားပေးပါ။
- Rendered Flutter UI
)What are Widgets? example ကို small/large screen, text scaling, empty/loading/error, rapid interaction, navigation restore နဲ့ disposal cases ဖြင့် run/test လုပ်ပါ။ flutter analyze, widget tests နဲ့ profile mode ကိုလိုအပ်သလိုသုံးပါ။
- Input + state
- Widget build + layout
- Rendered Flutter UI
Success
What are Widgets? ရဲ့ widget, state နဲ့ lifecycle behavior ကိုရှင်းပြနိုင်ရန်
Failure
UI တစ်ခုလုံးကို Container တစ်ခုထဲမှာအကုန်စုပြီးရေးတာက code ကိုဖတ်ရခက်စေပါတယ်။ Widget တွေကို တာဝန်အလိုက်ခွဲရေးပါ။
Flutter မှာ widget ဆိုတာ UI ကိုဖော်ပြတဲ့ building block ပါ။ Button တစ်ခု၊ စာသားတစ်ကြောင်း၊ padding တစ်ခု၊ layout တစ်ခု၊ screen တစ်ခုလုံး — အားလုံးက widget တွေပဲဖြစ်ပါတယ်။ Widget ကို object လို့မမြင်ဘဲ screen ပေါ်မှာ ဘာပုံစံပေါ်မလဲဆိုတဲ့ instruction card လို့မြင်ပါ။ Flutter app တစ်ခုကို widget tree အဖြစ်ဖွဲ့စည်းထားပါတယ်။ Parent widget က child widget ကိုကိုင်ထားပြီး child widget က နောက်ထပ် child တွေကိုဆက်ကိုင်နိုင်ပါတယ်။ ဒီ tree ကိုနားလည်ရင် layout, styling, state update တို့ကို ပိုမြန်မြန်နားလည်လာပါမယ်။
Scaffold(
appBar: AppBar(
title: const Text('Widget Tree'),
),
body: const Center(
child: Text('Every UI piece is a widget'),
),
)App bar ပါတဲ့ screen ပေါ်လာပြီး body အလယ်မှာ Every UI piece is a widget ဆိုတဲ့စာသားပေါ်ပါမယ်။နောက်တစ်ဆင့်
Widget အမျိုးအစားနှစ်ခုဖြစ်တဲ့ StatelessWidget နဲ့ StatefulWidget ကိုဆက်လေ့လာပါ။
Real-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
What are Widgets? example ကို small/large screen, text scaling, empty/loading/error, rapid interaction, navigation restore နဲ့ disposal cases ဖြင့် run/test လုပ်ပါ။ flutter analyze, widget tests နဲ့ profile mode ကိုလိုအပ်သလိုသုံးပါ။
Mini challenge
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
What are Widgets? example ကို small/large screen, text scaling, empty/loading/error, rapid interaction, navigation restore နဲ့ disposal cases ဖြင့် run/test လုပ်ပါ။ flutter analyze, widget tests နဲ့ profile mode ကိုလိုအပ်သလိုသုံးပါ။
- Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
- Normal input နဲ့ edge case စမ်းပါ
- Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
Scaffold(
appBar: AppBar(
title: const Text('Widget Tree'),
),
body: const Center(
child: Text('Every UI piece is a widget'),
),
)ရလဒ်: What are Widgets? ရဲ့ widget, state နဲ့ lifecycle behavior ကိုရှင်းပြနိုင်ရန်
အရိပ်အမြွက် ကြည့်ရန်
What are Widgets? example ကို small/large screen, text scaling, empty/loading/error, rapid interaction, navigation restore နဲ့ disposal cases ဖြင့် run/test လုပ်ပါ။ flutter analyze, widget tests နဲ့ profile mode ကိုလိုအပ်သလိုသုံးပါ။
Quick Quiz 1 / 3
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- Input + state → Widget build + layout → Rendered Flutter UI
- What are Widgets? ကို widget syntax အဖြစ်သာမမြင်ဘဲ constraints, size, position, rebuild scope, semantics နဲ့ platform adaptation contract အဖြစ်နားလည်ပါ။ Widget tree ကိုသေးသေးခွဲပြီး const widgets, lazy builders နဲ့ responsive constraints ကိုဦးစားပေးပါ။
- UI တစ်ခုလုံးကို Container တစ်ခုထဲမှာအကုန်စုပြီးရေးတာက code ကိုဖတ်ရခက်စေပါတယ်။ Widget တွေကို တာဝန်အလိုက်ခွဲရေးပါ။
- What are Widgets? example ကို small/large screen, text scaling, empty/loading/error, rapid interaction, navigation restore နဲ့ disposal cases ဖြင့် run/test လုပ်ပါ။ flutter analyze, widget tests နဲ့ profile mode ကိုလိုအပ်သလိုသုံးပါ။
Flutter documentation — Flutter