Thuta Learning
ရှာဖွေရန်
AdvancedMobile Developmentbeginner

Named Routes

စိတ်လျှော့ပါ။ ဒီခန်းကို စာအုပ်လိုမဟုတ်ဘဲ စကားပြောသလိုပဲ၊ နားလည်လွယ်အောင် ရှင်းပါမယ်။

Named Routes ဆိုတာ screen တွေကို string name နဲ့မှတ်ထားတဲ့ navigation နည်းလမ်းပါ။ Page အနည်းငယ်ပဲရှိတဲ့ project မှာ direct MaterialPageRoute ကရိုးရှင်းပေမဲ့ route များလာရင် '/profile', '/settings', '/details' ဆိုပြီး central place တစ်ခုမှာသတ်မှတ်ထားတာ ပိုရှင်းပါတယ်။

dart
MaterialApp(
  initialRoute: '/',
  routes: {
    '/': (context) => const HomeScreen(),
    '/details': (context) => const DetailScreen(),
    '/settings': (context) => const SettingsScreen(),
  },
);

// Navigate to settings
Navigator.pushNamed(context, '/settings');

// Go back
Navigator.pop(context);
You should see
Navigator.pushNamed(context, '/settings') ခေါ်လိုက်ရင် SettingsScreen ပေါ်လာပါမယ်။

နောက်တစ်ဆင့်

Navigation ပြီးရင် app ထဲမှာ image/file အသုံးပြုဖို့ Assets lesson ကိုဆက်ဖတ်ပါ။

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

  • routes ထဲမှာမရှိတဲ့ name ကို pushNamed ခေါ်ရင် route not found error ဖြစ်တတ်ပါတယ်။
Named Routes | Thuta Learning