Navigation
54 bites tagged Navigation — interview questions with model answers, and 60-second explainers.
MaterialPageRoute: The Page in Your Navigator Stack
Think of Navigator as a stack of screens. MaterialPageRoute wraps your new screen widget, defining its platform-specific transition (slide on iOS, zoom on Android). You use it with `Navigator.push` to show a new screen.
NavController: The Single Source of Truth for App Navigation
NavController is the central API for managing screen transitions. Think of it as an air traffic controller for your UI, directing users between destinations. It's the core of Jetpack Navigation, handling clicks that lead to new screens.
Android Navigation Graph: A Map for Your UI
Think of the Navigation Graph as a visual map of your app's screens. It centralizes all navigation logic in one XML file, defining destinations (screens) and actions (paths between them), simplifying transitions and deep linking.
Navigation Safe Args: Type-Safe Navigation in Android
Navigation Safe Args generates code to prevent runtime crashes when passing data between Android screens. It replaces error-prone Bundle manipulation with type-safe classes. Use it to pass user IDs or item details. The footgun: don't pass large objects.
Navigation in Compose
Navigation in Compose treats screens as state. You define a graph of composables, each with a string 'route', and navigate by changing the current route. It's ideal for single-activity apps.
Android's Task and Back Stack Explained
Think of the back stack as a stack of plates (screens). A "Task" is the entire stack for a user's workflow. The system manages this stack, but you can control it for custom navigation. The biggest footgun is misusing launch modes, which breaks back button.
Get Navigation bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.