Jetpack Navigation overview
The Jetpack Navigation library provides an API for handling complex navigation with ease while also following the principles of Android Jetpack. The library is available for both the old view system, which uses XML (https://developer.android.com/guide/navigation), and Jetpack Compose (https://developer.android.com/jetpack/compose/navigation). We will be learning about the latter in this chapter.
Still building on the Pets app we used in the previous chapter, we are going to navigate to a details screen that has a back button to the previous screen. We will also be passing data to the details screen.
To start with, we need to add the Jetpack Navigation Compose dependency to our project. Let’s add the following library inside the versions
section in our libs.versions.toml
file:
compose-navigation = "androidx.navigation:navigation-compose:2.7.2"
Next, we need to add the dependency to our app module’s build.gradle.kts
file...