Android Compose navigation arguments saved unnecessary

3 hours ago 1
ARTICLE AD BOX

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)) ... ComposableScreenB( id: () -> Long? = { backStackEntry.savedStateHandle.toRoute<ScreenB>().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<ScreenC>(inclusive = true), the id parameter again have value 3L as received at start from ScreenA.

How avoid saving old navigation parameter?

Read Entire Article