Mehdi Haghgoo
11/08/2020, 8:46 PMNavHost(navController, startDestination = "home"){
composable("new-item"){NewItem(navController)}
composable("profile/{name}", listOf(navArgument("name"){type = NavType.StringType}))
{navBackStackEntry ->
Profile(navBackStackEntry.arguments?.getString("name").toString())
}
composable("home?costName={costName}&costValue={costValue}",
arguments = listOf(navArgument("costName"){nullable = true}, navArgument("costValue"){type = NavType.IntType; defaultValue = 0})){
navBackStackEntry -> Home(navController, navBackStackEntry.arguments?.getString("costName"), navBackStackEntry.arguments?.getInt("costValue"))
}
}
// java.lang.IllegalArgumentException: navigation destination 150924488 is not a direct child of this NavGraph
// at androidx.navigation.NavGraphNavigator.navigate(NavGraphNavigator.java:66)
Ian Lake
11/08/2020, 8:52 PMhome
!= home?costName={costName}...
- those need to match exactlyMehdi Haghgoo
11/08/2020, 8:52 PMIan Lake
11/08/2020, 8:54 PMMehdi Haghgoo
11/08/2020, 9:02 PMNavHost(navController, startDestination = "home?costName=null&costValue=0"){
composable("new-item"){NewItem(navController)}
composable("profile/{name}", listOf(navArgument("name"){type = NavType.StringType}))
{navBackStackEntry ->
Profile(navBackStackEntry.arguments?.getString("name").toString())
}
composable("home?costName={costName}&costValue={costValue}",
arguments = listOf(navArgument("costName"){nullable = true}, navArgument("costValue"){type = NavType.IntType; defaultValue = 0})){
navBackStackEntry -> Home(navController, navBackStackEntry.arguments?.getString("costName"), navBackStackEntry.arguments?.getInt("costValue"))
}
}
// java.lang.IllegalArgumentException: navigation destination -423783418 is not a direct child of this NavGraph
Ian Lake
11/08/2020, 9:15 PMstartDestination="home?costName={costName}&costValue={costValue}"
composable
with the exact same route. It has nothing to do with starting arguments (which aren't supported at the moment - you'll always get only your default values for arguments for the start destination), etc.Mehdi Haghgoo
11/09/2020, 5:35 AMIan Lake
11/09/2020, 5:37 AMnavigate()
for returning a result