items

fun <T : Any> ScalingLazyListScope.items(items: LazyPagingItems<T>, key: (item: T) -> Any? = null, itemContent: @Composable ScalingLazyListItemScope.(value: T?) -> Unit)

Adds the LazyPagingItems and their content to the scope. The range from 0 (inclusive) to LazyPagingItems.itemCount (exclusive) always represents the full range of presentable items, because every event from PagingDataDiffer will trigger a recomposition.

Code from https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:paging/paging-compose/src/main/java/androidx/paging/compose/LazyPagingItems.kt

Parameters

items

the items received from a Flow of PagingData.

key

a factory of stable and unique keys representing the item. Using the same key for multiple items in the list is not allowed. Type of the key should be saveable via Bundle on Android. If null is passed the position in the list will represent the key. When you specify the key the scroll position will be maintained based on the key, which means if you add/remove items before the current visible item the item with the given key will be kept as the first visible one.

itemContent

the content displayed by a single item. In case the item is null, the itemContent method should handle the logic of displaying a placeholder instead of the main content displayed by an item which is not null.

Samples

androidx.paging.compose.samples.ItemsDemo