fix: handle invalid index in centerItem and return null for out-of-range subtitle indices

This commit is contained in:
2026-06-22 19:16:24 +02:00
parent 8926b3237b
commit feb3896727
3 changed files with 5 additions and 3 deletions
@@ -98,6 +98,8 @@ fun SubtitleList(
}
private suspend fun LazyListState.centerItem(index: Int) {
if (index < 0 || index >= this.layoutInfo.totalItemsCount) return
val info = this.layoutInfo
val viewportCenter = (info.viewportStartOffset + info.viewportEndOffset) / 2
val item = info.visibleItemsInfo.firstOrNull { it.index == index }