Navigasi dalam Flutter berpindah antara skrin (halaman/laluan) — menggunakan Navigator (timbunan laluan) untuk navigasi asas, atau pakej penghalaan deklaratif untuk aplikasi yang lebih kompleks. Memahami navigasi adalah penting untuk membina aplikasi berbilang skrin.
Navigasi asas dengan Navigator (satu timbunan)
// 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
