sealed interface ListScope


Receiver scope which is used by VerticalList.

Summary

Public functions

Unit
item(key: Any?, contentType: Any?, content: @Composable ListItemScope.() -> Unit)

Adds a single item.

Unit
items(
    count: Int,
    key: ((index: Int) -> Any)?,
    contentType: (index: Int) -> Any?,
    itemContent: @Composable ListItemScope.(index: Int) -> Unit
)

Adds a count of items.

Public functions

item

Added in 1.0.0-alpha01
fun item(key: Any? = null, contentType: Any? = null, content: @Composable ListItemScope.() -> Unit): Unit

Adds a single item.

Parameters
key: Any? = null

a 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.

contentType: Any? = null

the 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.

content: @Composable ListItemScope.() -> Unit

the content of the item

items

Added in 1.0.0-alpha01
fun items(
    count: Int,
    key: ((index: Int) -> Any)? = null,
    contentType: (index: Int) -> Any? = { null },
    itemContent: @Composable ListItemScope.(index: Int) -> Unit
): Unit

Adds a count of items.

Parameters
count: Int

the items count

key: ((index: Int) -> Any)? = null

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.

contentType: (index: Int) -> Any? = { null }

a 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.

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

the content displayed by a single item