StateFlow.value should not be called within composition
Because in composition you should be listening to events, not just reading the current one. If you read only the current one then your view won't get recomposed after the value is changed.
I mean - maybe there is a valid use case for that, but i never encountered one. I guess the warning you saw is just to warn users that they are trying to do something they probably don't want to
In my case, I added .collectAsState()
like this
@Composable
fun yourScreen() {
val state = viewModel.viewState.collectAsState()
when (state.value) {
// your code
}
}