I am facing an issue while using the code snippet from https://developer.android.com/guide/navigation/design#compose
@Serializable
object Profile
@Serializable
object FriendsList
val navController = rememberNavController()
NavHost(navController = navController, startDestination = Profile) {
composable<Profile> { ProfileScreen( /* ... / ) }
composable<FriendsList> { FriendsListScreen( / ... */ ) }
// Add more destinations similarly.
}
the startDestination
require string argument and not accepting the Profile object.
I am using "kotlinx-serialization-json" for @Serializable
annotation using Profile.toString()
works
Type safety in Kotlin DSL and Navigation Compose is available as of Navigation 2.8.0
. I was using Navigation 2.7.7
which current stable release. I needed to change the version.