Composables UI is out: our new component library for Compose Multiplatform ->
Interface

TransformingLazyColumnFirstLayoutItemProvider

Provides the first item to layout for TransformingLazyColumn.

Source set: Android
public fun interface TransformingLazyColumnFirstLayoutItemProvider

Provides the first item to layout for TransformingLazyColumn.

During a measurement pass, TransformingLazyColumn uses the item returned by this provider as the initial placement reference. TransformingLazyColumn measures this item and places its requested ItemInfo.itemEdge visual edge at the exact screen coordinate defined by ItemInfo.offset, prior to accounting for active scroll deltas. Once this initial item is positioned, all other visible items are sequentially composed and placed above and below it.

Providing this interface allows controlling how the list places its children during content updates like additions, removals, or item size changes.

Functions

getFirstLayoutItem

public fun getFirstLayoutItem(centerItem: ItemInfo): ItemInfo

Returns the ItemInfo for the first item to layout in TransformingLazyColumn.

Note: This method is executed internally inside a Snapshot.withoutReadObservation block. Any Compose state reads performed inside this callback will not trigger layout observation.

If the returned ItemInfo cannot be fully resolved (e.g., the key is not found or the index is out of bounds), TransformingLazyColumn falls back:

  • If the ItemInfo.key is not found, it falls back to the ItemInfo.index.
  • The final resolved index is coerced to stay within the valid list bounds.

Parameters

centerItem The ItemInfo that TransformingLazyColumn would currently use for the first layout item if no provider is supplied. Returning this item preserves the default layout behavior. In most cases, this is the item closest to the center of the viewport from TransformingLazyColumnLayoutInfo.visibleItems.

Returns

The ItemInfo of the item to use as the first item to layout.

Last updated: