You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior
This implementation works fine in Desktop and Ios but it get empty Keys in Android
Koin module and version:
Koin Bom 4.1.0-Beta3
Snippet or Sample project to help reproduce
Screen(AppScreens.BatchDetailScreen.route) { navBackStackEntry ->
val viewModel = koinInject(parameters = { parametersOf(navBackStackEntry.savedStateHandle) })
val uiState by viewModel.uiState.collectAsState()
BatchDetailScreen(uiState = uiState, interActor = viewModel.interActor)
}
The text was updated successfully, but these errors were encountered:
dhvanil-infotech
changed the title
SavedStateHandle with empty keys in Android. works fine on desktop
SavedStateHandle with empty keys in Android. works fine on desktop And Ios
Dec 31, 2024
Describe the bug
Navigation Arguments are not appearing in viewModel savedStateHandle in Android device
To Reproduce
DI Impl
viewModelOf(::BatchDetailViewModel)
init in composable
val viewModel = koinInject(parameters = { parametersOf(navBackStackEntry.savedStateHandle) })
class BatchDetailViewModel(
savedStateHandle: SavedStateHandle,
) : ViewModel() {
private val batchId = try {
println(savedStateHandle.keys())
savedStateHandle.get("json")?.toInt()?: 0
} catch (e: Exception) {
println("BatchId Error : ${e.message}")
0
}
}
Expected behavior
This implementation works fine in Desktop and Ios but it get empty Keys in Android
Koin module and version:
Koin Bom 4.1.0-Beta3
Snippet or Sample project to help reproduce
Screen(AppScreens.BatchDetailScreen.route) { navBackStackEntry ->
val viewModel = koinInject(parameters = { parametersOf(navBackStackEntry.savedStateHandle) })
val uiState by viewModel.uiState.collectAsState()
BatchDetailScreen(uiState = uiState, interActor = viewModel.interActor)
}
screens.forEach { screen ->
composable(
route = "${screen.route}?json={json}",
arguments = listOf(navArgument("json") {
type = NavType.StringType
defaultValue = ""
})
) { backStackEntry ->
screen.content(backStackEntry)
}
}
The text was updated successfully, but these errors were encountered: