fix: drawScrollbar crash on list with 0 item but only sticky header (#1083)

(cherry picked from commit 04db46fe75c2406fe9750e97da65774a6b268f27)
This commit is contained in:
Tran M. Cuong 2024-08-06 21:38:56 +07:00 committed by Jobobby04
parent 70a8bef7a5
commit d655b8ecdf

View File

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