androidx.compose.foundation.lazy.layout

LazyLayoutItemProvider

Interface · from org.jetbrains.compose.foundation:foundation:1.12.2

No hand-written docs yet.

Provides all the needed info about the items which could be later composed and displayed as children or LazyLayout. The number of virtual items is limited by LazyLayoutItemProvider.itemCount. For an efficient implementation this should be an immutable representation of the underlying data/items, ideally changes to your data source/structure should re-create this representation, instead of changing state values read inside this implementation. See LazyLayout for additional context.

interface LazyLayoutItemProvider

Properties

itemCount

val itemCount: Int

The total number of items in the lazy layout (visible or not).

Functions

Item

@Composable
fun Item(index: Int, key: Any)

The item for the given index and key. Indices are a core concept on LazyLayouts and should always be supported, the key is an additional concept that can be introduced per item and is used to guaranteed the uniqueness of a given item in the Lazy Layout implementation. For instance, in lists, keys are used to keep an item's scroll position in case of dataset changes. Therefore, the key provided here will depend if your LazyLayout implementation supports this concept or not.

getContentType

fun getContentType(index: Int): Any?

Returns the content type for the item on this index. It is used to improve the item compositions reusing efficiency. Note that null is a valid type and items of such type will be considered compatible.

getKey

fun getKey(index: Int): Any

Returns the key for the item on this index.

getIndex

fun getIndex(key: Any): Int

Get index for given key. The index is not guaranteed to be known for all keys in layout for optimization purposes, but must be present for elements in current viewport. If the key is not present in the layout or is not known, return -1.

Library docs

Provides all the needed info about the items which could be later composed and displayed as children or LazyLayout. The number of virtual items is limited by LazyLayoutItemProvider.itemCount. For an efficient implementation this should be an immutable representation of the underlying data/items, ideally changes to your data source/structure should re-create this representation, instead of changing state values read inside this implementation. See LazyLayout for additional context.