Issue
Error:
java.lang.IllegalArgumentException: Navigation destination that matches request NavDeepLinkRequest{ uri=android-app://androidx.navigation/book_screen } cannot be found
animatedCompose("${Graph.BOOK}/{id}",
arguments = listOf(
navArgument("id"){
type = NavType.LongType
defaultValue = -1
}
)
){
val id = it.arguments?.getInt("id") ?: -1
val actionText = if(id != -1) "Save" else "Add"
val title = if(id != -1) "Edit Book" else "Add New Book"
BookScreen(navHostController, title=title, actionText=actionText)
}
From within another screen:
Scaffold(
floatingActionButton = {
FloatingActionButton(onClick = {
rootNavHostController.navigate(Graph.BOOK)
}) {
Icon(Icons.Filled.Add,null)
}
}
I assume, that you can make the {id}
optional as an argument. But, not sure of why things don't work at this moment.
Solution
Solved it by doing this:
animatedCompose("${Graph.BOOK}/?id={id}",
arguments = listOf(
navArgument("id"){
type = NavType.IntType
defaultValue = -1
}
){}
Answered By - Alix Blaine
Answer Checked By - Gilberto Lyons (JavaFixing Admin)