1
0

More than 1 year has passed since last update.

Jetpack Composeの内部でIndex should be non-negativeが発生する原因の一つ

Posted at
java.lang.IllegalArgumentException: Index should be non-negative (-1)
    at androidx.compose.foundation.lazy.LazyListScrollPosition.update-AhXoVpI(LazyListScrollPosition.kt:98)
    at androidx.compose.foundation.lazy.LazyListScrollPosition.updateScrollPositionIfTheFirstItemWasMoved(LazyListScrollPosition.kt:94)
    at androidx.compose.foundation.lazy.LazyListState.updateScrollPositionIfTheFirstItemWasMoved$foundation_release(LazyListState.kt:301)

rememberLazyListState(initialFirstVisibleItemIndex = -1) とinitialFirstVisibleItemIndexに負の値を指定すると内部で例外が発生する。
指定した箇所(rememberLazyListState)ではなく内部で発生しているので原因を特定するのが結構難しかった

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0