What is Navigator in Flutter?
Why Interviewers Ask This
Candidates at the intermediate level are expected to not only know this concept but explain the trade-offs involved. Interviewers use this question to see if you can reason about design decisions, not just recall facts.
Answer
The Navigator manages a stack of routes (screens) in a Flutter app. Navigator.push() pushes a new route on top of the stack (navigates forward), and Navigator.pop() removes the top route (navigates back). Navigator.pushReplacement() replaces the current route — useful for the login → home transition so the user cannot go back to login. For named routes, use Navigator.pushNamed(context, "/home"). Flutter 2.0 introduced the Navigator 2.0 (Router) API for URL-based navigation.
Pro Tip
Before answering, structure your response: one-line definition → real-world analogy → concrete example from a project. This makes even complex Flutter answers easy to follow.