Aditya Wasan

    Aditya Wasan

    1 year ago
    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
    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

    P.J.

    1 year ago
    What version are you on? Should be fixed in alpha05. Check this thread https://kotlinlang.slack.com/archives/CJLTWPH7S/p1601591645354200
    Aditya Wasan

    Aditya Wasan

    1 year ago
    Oh I'm on alpha04, will try with alpha05.
    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.