Navigation in Jetpack Compose

Sep 10 2024 · Kotlin 1.9, Android 14, Android Studio Jellyfish

Lesson 02: Use Navigation Arguments

Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this demo, you’ll continue to build on the movie booking application from the previous lesson.

composable(
  TICKET_SELECTION_SCREEN.route,
  arguments = listOf(navArgument("movieName") { type = NavType.StringType })
) { backStackEntry ->
  TicketSelectionScreen(
    movieName = requireNotNull(
      backStackEntry.arguments?.getString(MOVIE_NAME_ARG)
    )
  )
}
TICKET_SELECTION_SCREEN("ticket-selection/{$MOVIE_NAME_ARG}"),
MovieSelectionScreen(onNextClick = { movieName ->
  navController.navigate(
    TICKET_SELECTION_SCREEN.route.replace(
      "{$MOVIE_NAME_ARG}",
      movieName
    )
  )
})
See forum comments
Cinema mode Download course materials from Github
Previous: Instruction Next: Conclusion