Aditya Wasan
10/18/2020, 8:56 AMLazyColumnForIndexed
where the items change due to a boolean condition. However, if I've scrolled more than the size of the second list and then try to switch to the second list the app crashes with
java.lang.IllegalStateException: entered drag with non-zero pending scroll: -1638.0
Just wanted to know if it's a bug or that's how it is intended to work.
LazyColumnForIndexed(
items = if (showSaved.value) savedPostsState.value else hottestPostsState.value,
modifier = Modifier.padding(horizontal = 8.dp)
) { index, item ->
P.J.
10/18/2020, 10:24 AMAditya Wasan
10/18/2020, 10:28 AMval hottestPostsListState = rememberLazyListState()
val savedPostsListState = rememberLazyListState()
LazyColumnForIndexed(
items = if (showSaved.value) savedPostsState.value else hottestPostsState.value,
state = if (showSaved.value) savedPostsListState else hottestPostsListState,
modifier = Modifier.padding(horizontal = 8.dp)
) { index, item ->
Also, using different LazyListState for each list helped prevent the crash.