Start native apps faster with the Composables CLI ->
Function

requestScrollToItem

Requests the item at index to be at the start of the viewport during the next remeasure, offset by scrollOffset, and schedules a remeasure.

requestScrollToItem

Source set: Common
public fun requestScrollToItem(@AndroidXIntRange(from = 0) index: Int, scrollOffset: Int = 0)

Requests the item at index to be at the start of the viewport during the next remeasure, offset by scrollOffset, and schedules a remeasure.

The scroll position will be updated to the requested position rather than maintain the index based on the first visible item key (when a data set change will also be applied during the next remeasure), but only for the next remeasure.

Any scroll in progress will be cancelled.

Parameters

index the index to which to scroll. Must be non-negative.
scrollOffset the offset that the item should end up after the scroll. Note that positive offset refers to forward scroll, so in a top-to-bottom list, positive offset will scroll the item further upward (taking it partly offscreen).