Android Compose navigation arguments saved unnecessary
14:28 17 Dec 2025

While using android navigation compose have a problem with saved navigation arguments.

For example, i have routes:

@Serializable
object ScreenA

@Serializable
data class ScreenB(val id: Long? = null)

@Serializable
object ScreenC

At first, i am navigate from ScreenA to ScreenB with parameter and open ComposableScreenB:

...
navController.navigate(ScreenB(3L))
...
composable { backStackEntry ->
    ComposableScreenB(
        id: () -> Long? = { backStackEntry.savedStateHandle.toRoute().id }
    )
}

I am use parameter value in ComposableScreenB and then navigation parameter is unnecessary. But after navigation to ScreenC and navigate up to ScreenB by navController.popBackStack(inclusive = true), the id parameter again have value 3L as received at start from ScreenA.

How avoid saving old navigation parameter?

android android-jetpack-compose android-navigation