📱 Flutter
Intermediate
What is Navigator.pushReplacement() in Flutter?
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().
Previous
What is ValueNotifier in Flutter?
Next
What is AnimationController in Flutter and how do you use it?