Hey everyone I added this code to my composable An...
# compose
v
Hey everyone I added this code to my composable And now my app just freezes and gives ANR
Copy code
LaunchedEffect(listState){
        snapshotFlow { listState.layoutInfo.visibleItemsInfo }
            .filterNot { it.isEmpty() }
            .filterNot { it.first().index >= threads.indices.last }
            .filterNot { threads.isEmpty() }
            .collect { listState.scrollToItem(threads.lastIndex) }
    }
Any idea whats wrong in it?
d
May have something to do with the fact that scrolling affects the visible items.
1
To test my theory try moving the scrollToItem outside the collect. So unsubscribe from the flow before scrolling.
v
Ahh, maybe getting caught in an infinite loop