LazyListScope

Interface

Common
@LazyScopeMarker
@JvmDefaultWithCompatibility
interface LazyListScope

Receiver scope which is used by LazyColumn and LazyRow.

Functions

fun item(
        key: Any? = null,
        contentType: Any? = null,
        content: @Composable LazyItemScope.() -> Unit,
    )

Adds a single item.

Parameters

keya stable and unique key 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. This can be overridden by calling 'requestScrollToItem' on the 'LazyListState'.
contentTypethe type of the content of this item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.
contentthe content of the item
fun item(key: Any? = null, content: @Composable LazyItemScope.() -> Unit)
fun items(
        count: Int,
        key: ((index: Int) -> Any)? = null,
        contentType: (index: Int) -> Any? = { null },
        itemContent: @Composable LazyItemScope.(index: Int) -> Unit,
    )

Adds a count of items.

Parameters

countthe items count
keya 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. This can be overridden by calling 'requestScrollToItem' on the 'LazyListState'.
contentTypea factory of the content types for the item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.
itemContentthe content displayed by a single item
fun items(
        count: Int,
        key: ((index: Int) -> Any)? = null,
        itemContent: @Composable LazyItemScope.(index: Int) -> Unit,
    )
fun stickyHeader(
        key: Any? = null,
        contentType: Any? = null,
        content: @Composable LazyItemScope.() -> Unit,
    ) = stickyHeader(key, contentType) { _ -> content() }

Adds a sticky header item, which will remain pinned even when scrolling after it. The header will remain pinned until the next header will take its place.

Parameters

keya stable and unique key 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. This can be overridden by calling 'requestScrollToItem' on the 'LazyListState'.
contentTypethe type of the content of this item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.
contentthe content of the header
fun stickyHeader(
        key: Any? = null,
        contentType: Any? = null,
        content: @Composable LazyItemScope.(Int) -> Unit,
    )

Adds a sticky header item, which will remain pinned even when scrolling after it. The header will remain pinned until the next header will take its place.

Parameters

keya stable and unique key 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. This can be overridden by calling 'requestScrollToItem' on the 'LazyListState'.
contentTypethe type of the content of this item. The item compositions of the same type could be reused more efficiently. Note that null is a valid type and items of such type will be considered compatible.
contentthe content of the header, the header index is provided, this is the item position within the total set of items in this lazy list (the global index).