Tom Truyen
07/06/2024, 6:08 PMval backStackEntry by navController.currentBackStackEntryAsState()
LaunchedEffect(backStackEntry) {
val route: Route = backStackEntry?.toRoute() // Always returns null, even when backStackEntry route is not null
}
I currently am using a workaround using the qualified name:
val route = backStackEntry?.destination?.route == Screen.Profile::class.qualifiedName
Though I would prefer a better method.
I personally would expect that if I do toRoute() I could do a check like route is Screen.Profile
but since toRoute always returns null this check will always fail
The way I have build my routes:
sealed interface Screen {
sealed interface Auth: Screen {
@Serializable
data object Login : Auth
@Serializable
data object Register: Auth
}
@Serializable
data object Profile: Screen
}
Chrimaeon
07/06/2024, 6:50 PMTom Truyen
07/06/2024, 7:36 PMTom Truyen
07/06/2024, 7:36 PMkotlinforandroid
04/02/2025, 12:10 PMhasRoute<Screeb.Auth>()
wouldn't work for example.Tom Truyen
04/02/2025, 12:20 PM