I have tried all possible way looks like not getting a solution to this.
I am using an all compose app with compose screens and using compose navigation to navigate between this screen, I have a scenario where I am navigating further in this manner
Screen A > Screen B1 >..> Screen BN > Screen C
Now After I have done with the function on Screen C, I want to pop back to Screen A but this time with an optional argument for eg: Success
I have done this to navigate to A:
val route = "ScreenA?arg={arg}"
// navigating like this
navController.navigate("ScreenA")
// handling
composable(route, arguments = listOf(navArgument("arg") { nullable = true })){
ScreenA()
}
Now for popping back to ScreenA from where ever I am I have done this:
navController.popBackStack(
route = route,
inclusive = false
)
I want to send argument now while popping back. I have tried adding route as
ScreenA?arg=success
Which Doesn't work as inside popBackStack function, it checks the hashcode of the route
popBackStack(createRoute(route).hashCode(), inclusive, saveState)
in this case my navigation fails
I have tried setting argument to back stack entry also but as it can be N Screen in between it wont work. Need to understand where I am doing wrong or if theres a way to do it?