What is Navigator.pushReplacement() in Flutter?
Why Interviewers Ask This
This tests whether you can apply Flutter knowledge to real-world scenarios. Interviewers are looking for clarity of thought and evidence that you've encountered this in production code.
Answer
Navigator.pushReplacement() navigates to a new screen while simultaneously removing the current screen from the navigation stack. This means the user cannot press the back button to return to the previous screen. It is the correct choice for post-login navigation (from login screen to home) or when transitioning between onboarding steps where going back does not make sense. For clearing the entire stack and starting fresh, use Navigator.pushAndRemoveUntil().
Common Mistake
Don't just define the term — demonstrate that you understand when to use it and when not to. Showing awareness of trade-offs is what separates average from strong Flutter candidates.
Previous
What is ValueNotifier in Flutter?
Next
What is AnimationController in Flutter and how do you use it?