class DetailViewModel : ViewModel() {
val textState = MutableStateFlow("test")
init {
viewModelScope.launch {
delay(300)
textState.value = "this is a performance test" // skip frames when updating text
}
}
}
UI:
private fun Detail() {
val vm: DetailViewModel = viewModel()
val text by vm.textState.collectAsState()
Column(
modifier = Modifier
.fillMaxSize()
.background(Color.Gray),
) {
for (i in 1..100)
Text(text = text)
}
}
version: 1.11.7 navigation-compose version: 2.8.3 Navigation animation is laggy when ui changes.
Here is a simple demo, when navigating to Detail from any destination, skip frames occur when updating the text.
Navigation animation is:
ViewModel:
UI: