Flutter

Navigation & Routing

Navigator 1.0/2.0, routes, MaterialPageRoute, Router API, go_router, deep linking, named routes

22 面接問題·
Mid-Level
1

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.

2

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.

3

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.

4

How to define named routes in a Flutter application?

5

What is the difference between Navigator.pushReplacement() and Navigator.push()?

+19 面接問題

次の面接に向けてFlutterをマスター

すべての問題、flashcards、技術テスト、コードレビュー演習、面接シミュレーターにアクセス。

無料で始める