LazyListScope

@LazyScopeMarker
interface LazyListScope


Receiver scope which is used by LazyColumn.

Summary

Constants

const Long

Public functions

Unit
item(itemId: Long, content: @Composable LazyItemScope.() -> Unit)

Adds a single item.

Unit
items(
    count: Int,
    itemId: (index: Int) -> Long,
    itemContent: @Composable LazyItemScope.(index: Int) -> Unit
)

Adds a count of items.

Extension functions

inline Unit
<T : Any?> LazyListScope.items(
    items: Array<T>,
    noinline itemId: (item) -> Long,
    crossinline itemContent: @Composable LazyItemScope.(item) -> Unit
)

Adds an array of items.

inline Unit
<T : Any?> LazyListScope.items(
    items: List<T>,
    crossinline itemId: (item) -> Long,
    crossinline itemContent: @Composable LazyItemScope.(item) -> Unit
)

Adds a list of items.

inline Unit
<T : Any?> LazyListScope.itemsIndexed(
    items: Array<T>,
    noinline itemId: (index: Int, item) -> Long,
    crossinline itemContent: @Composable LazyItemScope.(index: Int, item) -> Unit
)

Adds a array of items where the content of an item is aware of its index.

inline Unit
<T : Any?> LazyListScope.itemsIndexed(
    items: List<T>,
    crossinline itemId: (index: Int, item) -> Long,
    crossinline itemContent: @Composable LazyItemScope.(index: Int, item) -> Unit
)

Adds a list of items where the content of an item is aware of its index.

Constants

UnspecifiedItemId

Added in 1.0.0
const val UnspecifiedItemIdLong

Public functions

item

Added in 1.0.0
fun item(itemId: Long = UnspecifiedItemId, content: @Composable LazyItemScope.() -> Unit): Unit

Adds a single item.

Parameters
itemId: Long = UnspecifiedItemId

a stable and unique id representing the item. The value may not be less than or equal to -2^62, as these values are reserved by the Glance API. Specifying the list item ids will maintain the scroll position through app widget updates in Android S and higher devices.

content: @Composable LazyItemScope.() -> Unit

the content of the item

items

Added in 1.0.0
fun items(
    count: Int,
    itemId: (index: Int) -> Long = { UnspecifiedItemId },
    itemContent: @Composable LazyItemScope.(index: Int) -> Unit
): Unit

Adds a count of items.

Parameters
count: Int

the count of items

itemId: (index: Int) -> Long = { UnspecifiedItemId }

a factory of stable and unique ids representing the item. The value may not be less than or equal to -2^62, as these values are reserved by the Glance API. Specifying the list item ids will maintain the scroll position through app widget updates in Android S and higher devices.

itemContent: @Composable LazyItemScope.(index: Int) -> Unit

the content displayed by a single item

Extension functions

inline fun <T : Any?> LazyListScope.items(
    items: Array<T>,
    noinline itemId: (item) -> Long = { LazyListScope.UnspecifiedItemId },
    crossinline itemContent: @Composable LazyItemScope.(item) -> Unit
): Unit

Adds an array of items.

Parameters
items: Array<T>

the data array

noinline itemId: (item) -> Long = { LazyListScope.UnspecifiedItemId }

a factory of stable and unique list item ids. Using the same itemId for multiple items in the array is not allowed. When you specify the itemId, the scroll position will be maintained based on the itemId, which means if you add/remove items before the current visible item the item with the given itemId will be kept as the first visible one.

crossinline itemContent: @Composable LazyItemScope.(item) -> Unit

the content displayed by a single item

inline fun <T : Any?> LazyListScope.items(
    items: List<T>,
    crossinline itemId: (item) -> Long = { LazyListScope.UnspecifiedItemId },
    crossinline itemContent: @Composable LazyItemScope.(item) -> Unit
): Unit

Adds a list of items.

Parameters
items: List<T>

the data list

crossinline itemId: (item) -> Long = { LazyListScope.UnspecifiedItemId }

a factory of stable and unique ids representing the item. The value may not be less than or equal to -2^62, as these values are reserved by the Glance API. Specifying the list item ids will maintain the scroll position through app widget updates in Android S and higher devices.

crossinline itemContent: @Composable LazyItemScope.(item) -> Unit

the content displayed by a single item

inline fun <T : Any?> LazyListScope.itemsIndexed(
    items: Array<T>,
    noinline itemId: (index: Int, item) -> Long = { _, _ -> LazyListScope.UnspecifiedItemId },
    crossinline itemContent: @Composable LazyItemScope.(index: Int, item) -> Unit
): Unit

Adds a array of items where the content of an item is aware of its index.

Parameters
items: Array<T>

the data array

noinline itemId: (index: Int, item) -> Long = { _, _ -> LazyListScope.UnspecifiedItemId }

a factory of stable and unique list item ids. Using the same itemId for multiple items in the array is not allowed. When you specify the itemId the scroll position will be maintained based on the itemId, which means if you add/remove items before the current visible item the item with the given itemId will be kept as the first visible one.

crossinline itemContent: @Composable LazyItemScope.(index: Int, item) -> Unit

the content displayed by a single item

inline fun <T : Any?> LazyListScope.itemsIndexed(
    items: List<T>,
    crossinline itemId: (index: Int, item) -> Long = { _, _ -> LazyListScope.UnspecifiedItemId },
    crossinline itemContent: @Composable LazyItemScope.(index: Int, item) -> Unit
): Unit

Adds a list of items where the content of an item is aware of its index.

Parameters
items: List<T>

the data list

crossinline itemId: (index: Int, item) -> Long = { _, _ -> LazyListScope.UnspecifiedItemId }

a factory of stable and unique ids representing the item. The value may not be less than or equal to -2^62, as these values are reserved by the Glance API. Specifying the list item ids will maintain the scroll position through app widget updates in Android S and higher devices.

crossinline itemContent: @Composable LazyItemScope.(index: Int, item) -> Unit

the content displayed by a single item