Navigation & Routing
Navigator 1.0/2.0, routes, MaterialPageRoute, Router API, go_router, deep linking, named routes
1Which method should be used to navigate to a new screen with Navigator 1.0?
Which method should be used to navigate to a new screen with Navigator 1.0?
답변
Navigator.push() adds a new route to the navigation stack, allowing navigation to a new screen while keeping the previous screen in the stack. This method takes context and a Route (usually MaterialPageRoute) as parameters. Push stacks the new route, while pop removes it from the stack.
2What does Navigator.pop() return when sending data back to the previous screen?
What does Navigator.pop() return when sending data back to the previous screen?
답변
Navigator.pop() can take an optional argument that will be returned to the previous screen via the Future returned by Navigator.push(). This allows sending a result (confirmation, selection, modified data) back to the screen that initiated navigation. Use await with push() to retrieve this result.
3What is the role of MaterialPageRoute in Flutter navigation?
What is the role of MaterialPageRoute in Flutter navigation?
답변
MaterialPageRoute is a route that uses Material Design transitions (slide from right on iOS, fade on Android). It takes a builder that returns the destination widget. It automatically handles transition animations and respects platform conventions for a native user experience.
How to define named routes in a Flutter application?
What is the difference between Navigator.pushReplacement() and Navigator.push()?
+19 면접 질문