Flutter में navigation screens (pages/routes) के बीच ले जाता है — मूल navigation के लिए Navigator (routes का एक stack) का उपयोग करते हुए, या अधिक जटिल apps के लिए declarative routing packages। navigation को समझना multi-screen apps बनाने के लिए आवश्यक है।
Navigator के साथ मूल navigation (एक stack)
// the Navigator manages a STACK of routes (screens)
// PUSH a new screen onto the stack (navigate to it)
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondScreen()),
);
// POP — go back (remove the top screen, return to the previous)
Navigator.pop(context);
Think of navigation as a STACK of screens:
→ PUSH adds a screen on top (navigate forward)
→ POP removes the top screen (go back)
→ the back button / gesture also pops
