Navigation ใน Flutter คือการย้ายระหว่างหน้าจอ (page/route) — โดยใช้ Navigator (stack ของ route) สำหรับ navigation พื้นฐาน หรือ package routing แบบ declarative สำหรับแอปที่ซับซ้อนกว่า การเข้าใจ navigation เป็นสิ่งจำเป็นต่อการสร้างแอปแบบหลายหน้าจอ
navigation พื้นฐานด้วย Navigator (เป็น 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
