fix: drawScrollbar crash on list with 0 item but only sticky header

This commit is contained in:
Tran M. Cuong 2024-08-06 21:38:56 +07:00 committed by Cuong-Tran
parent f5394facf1
commit 6d55f200d0
No known key found for this signature in database
GPG key ID: 733AA7624B9315C2

View file

@ -119,15 +119,15 @@ private fun Modifier.drawScrollbar(
0f 0f
} else { } else {
items items
.fastFirstOrNull { (it.key as? String)?.startsWith(STICKY_HEADER_KEY_PREFIX)?.not() ?: true }!! .fastFirstOrNull { (it.key as? String)?.startsWith(STICKY_HEADER_KEY_PREFIX)?.not() ?: true }
.run { ?.run {
val startPadding = if (reverseDirection) { val startPadding = if (reverseDirection) {
layoutInfo.afterContentPadding layoutInfo.afterContentPadding
} else { } else {
layoutInfo.beforeContentPadding layoutInfo.beforeContentPadding
} }
startPadding + ((estimatedItemSize * index - offset) / totalSize * viewportSize) startPadding + ((estimatedItemSize * index - offset) / totalSize * viewportSize)
} } ?: 0f
} }
val drawScrollbar = onDrawScrollbar( val drawScrollbar = onDrawScrollbar(
orientation, reverseDirection, atEnd, showScrollbar, orientation, reverseDirection, atEnd, showScrollbar,