@@ -46,6 +46,10 @@ import androidx.navigation.compose.composable
4646import androidx.navigation.compose.rememberNavController
4747import kotlin.coroutines.cancellation.CancellationException
4848import kotlinx.coroutines.flow.Flow
49+ import kotlinx.serialization.Serializable
50+
51+ @Serializable data object Home
52+ @Serializable data object Settings
4953
5054@Composable
5155private fun PredictiveBackOverrideExit (
@@ -56,7 +60,7 @@ private fun PredictiveBackOverrideExit(
5660 // [START android_compose_predictiveback_navhost]
5761 NavHost (
5862 navController = navController,
59- startDestination = " home " ,
63+ startDestination = Home ,
6064 popExitTransition = {
6165 scaleOut(
6266 targetScale = 0.9f ,
@@ -70,13 +74,13 @@ private fun PredictiveBackOverrideExit(
7074 )
7175 // [END android_compose_predictiveback_navhost]
7276 {
73- composable( " home " ) {
77+ composable< Home > {
7478 HomeScreen (
7579 modifier = modifier,
7680 navController = navController,
7781 )
7882 }
79- composable( " settings " ) {
83+ composable< Settings > {
8084 SettingsScreen (
8185 modifier = modifier,
8286 navController = navController,
@@ -119,6 +123,7 @@ private fun PredictiveBackHandlerBasicExample() {
119123 boxScale = 1F - (1F * backEvent.progress)
120124 }
121125 // code for completion
126+ boxScale = 0F
122127 } catch (e: CancellationException ) {
123128 // code for cancellation
124129 boxScale = 1F
0 commit comments