Navigation3 - Part 1 and 2 Dependencies

Navigation 3 

Part 1 and 2 Dependencies

Add these dependencies before you start with the examples. Just add / adjust as required. You should not need to remove any existing entries from a new project.

build.gradle.kts (Project: ProjectName)

plugins {
...
// Added for Navigation3
alias(libs.plugins.kotlin.serialization) apply false
}

build.gradle.kts (Module: app) 

plugins {
...
// Added for Navigation3
alias(libs.plugins.kotlin.serialization)
}

android {
...
compileSdk {
version = release(37)
}
...
defaultConfig {

targetSdk = 37

}
}

dependencies {
...
// Added - ViewModel
implementation(libs.androidx.lifecycle.viewmodel.compose)

// Added - Navigation3
implementation(libs.androidx.navigation3.runtime)
implementation(libs.androidx.navigation3.ui)

implementation(libs.kotlinx.serialization.core)

// Added for list/detail
implementation(libs.androidx.compose.adaptive.navigation3)
}

libs.versions.toml

It was far easier to post the full code - GitHub Gist Full List.

NavigationScreen - Shared

@Serializable
sealed interface NavigationScreen : NavKey {

@Serializable
data object Home : NavigationScreen

@Serializable
data object List : NavigationScreen

@Serializable
data class Detail(val id: Int) : NavigationScreen
}

Cute Dependency Picture

Comments

Popular Posts