https://kotlinlang.org logo
#compose
Title
# compose
a

Aditya Wasan

10/18/2020, 8:56 AM
Hey, I have a
LazyColumnForIndexed
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
Copy code
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.
Copy code
LazyColumnForIndexed(
    items = if (showSaved.value) savedPostsState.value else hottestPostsState.value,
    modifier = Modifier.padding(horizontal = 8.dp)
  ) { index, item ->
p

P.J.

10/18/2020, 10:24 AM
What version are you on? Should be fixed in alpha05. Check this thread https://kotlinlang.slack.com/archives/CJLTWPH7S/p1601591645354200
a

Aditya Wasan

10/18/2020, 10:28 AM
Oh I'm on alpha04, will try with alpha05.
Copy code
val 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.
9 Views