# LazyListScope

# LazyListScope

Artifact:[androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance)  
[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/lazy/LazyList.kt+class:androidx.glance.appwidget.lazy.LazyListScope)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/glance#1.0.0)

<br />

```
@LazyScopeMarker
interface LazyListScope
```

<br />

*** ** * ** ***

Receiver scope which is used by[LazyColumn](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/package-summary#LazyColumn(androidx.glance.GlanceModifier,androidx.glance.layout.Alignment.Horizontal,kotlin.Function1)).

## Summary

|                                     ### Constants                                     |
|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| `const `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) | [UnspecifiedItemId](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#UnspecifiedItemId()) |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [item](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#item(kotlin.Long,kotlin.Function1))`(itemId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`, content: @`[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.() `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)`)` Adds a single item.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [items](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#items(kotlin.Int,kotlin.Function1,kotlin.Function2))`(` ` count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` itemId: (index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` itemContent: @`[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) `)` Adds a[count](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#items(kotlin.Int,kotlin.Function1,kotlin.Function2))of items. |

|                                ### Extension functions                                 |
|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `inline `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | `<T : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?> `[LazyListScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope)`.`[items](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#(androidx.glance.appwidget.lazy.LazyListScope).items(kotlin.Array,kotlin.Function1,kotlin.Function2))`(` ` items: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<T>,` ` noinline itemId: (item) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` crossinline itemContent: @`[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(item) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) `)` Adds an array of items.                                                                                                                                                                                                                                                                    |
| `inline `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | `<T : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?> `[LazyListScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope)`.`[items](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#(androidx.glance.appwidget.lazy.LazyListScope).items(kotlin.collections.List,kotlin.Function1,kotlin.Function2))`(` ` items: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<T>,` ` crossinline itemId: (item) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` crossinline itemContent: @`[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(item) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) `)` Adds a list of items.                                                                                                                                                                                                                                              |
| `inline `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | `<T : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?> `[LazyListScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope)`.`[itemsIndexed](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#(androidx.glance.appwidget.lazy.LazyListScope).itemsIndexed(kotlin.Array,kotlin.Function2,kotlin.Function3))`(` ` items: `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<T>,` ` noinline itemId: (index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, item) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` crossinline itemContent: @`[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, item) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) `)` Adds a array of items where the content of an item is aware of its index.                        |
| `inline `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | `<T : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?> `[LazyListScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope)`.`[itemsIndexed](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#(androidx.glance.appwidget.lazy.LazyListScope).itemsIndexed(kotlin.collections.List,kotlin.Function2,kotlin.Function3))`(` ` items: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<T>,` ` crossinline itemId: (index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, item) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` crossinline itemContent: @`[Composable](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, item) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) `)` Adds a list of items where the content of an item is aware of its index. |

## Constants

### UnspecifiedItemId

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/glance#1.0.0)  

```
const val UnspecifiedItemId: Long
```  

## Public functions

### item

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/glance#1.0.0)  

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

Adds a single item.  

|                                                                                                                                                     Parameters                                                                                                                                                      |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `itemId: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` = 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](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.() `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | the content of the item                                                                                                                                                                                                                                                     |

### items

Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/glance#1.0.0)  

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

Adds a[count](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyListScope#items(kotlin.Int,kotlin.Function1,kotlin.Function2))of items.  

|                                                                                                                                                                                                 Parameters                                                                                                                                                                                                  |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                                                                                                                                                                                                        | the count of items                                                                                                                                                                                                                                                                      |
| `itemId: (index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` = { 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](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | the content displayed by a single item                                                                                                                                                                                                                                                  |

## Extension functions

### items

Artifact:[androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance)  
[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/lazy/LazyList.kt+function:items)  

```
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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<T>`                                                                                                                                                                                                                                           | the data array                                                                                                                                                                                                                                                                                                                                         |
| `noinline itemId: (item) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` = { 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](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(item) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | the content displayed by a single item                                                                                                                                                                                                                                                                                                                 |

### items

Artifact:[androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance)  
[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/lazy/LazyList.kt+function:items)  

```
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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<T>`                                                                                                                                                                                                                                 | the data list                                                                                                                                                                                                                                                                           |
| `crossinline itemId: (item) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` = { 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](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(item) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | the content displayed by a single item                                                                                                                                                                                                                                                  |

### itemsIndexed

Artifact:[androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance)  
[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/lazy/LazyList.kt+function:itemsIndexed)  

```
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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<T>`                                                                                                                                                                                                                                                                                                                                 | the data array                                                                                                                                                                                                                                                                                                                                        |
| `noinline itemId: (index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, item) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` = { _, _ -> 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](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, item) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | the content displayed by a single item                                                                                                                                                                                                                                                                                                                |

### itemsIndexed

Artifact:[androidx.glance:glance-appwidget](https://developer.android.com/jetpack/androidx/releases/glance)  
[View Source](https://cs.android.com/search?q=file:androidx/glance/appwidget/lazy/LazyList.kt+function:itemsIndexed)  

```
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](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<T>`                                                                                                                                                                                                                                                                                                                       | the data list                                                                                                                                                                                                                                                                           |
| `crossinline itemId: (index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, item) `->` `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)` = { _, _ -> 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](https://developer.android.com/reference/kotlin/androidx/compose/runtime/Composable)` `[LazyItemScope](https://developer.android.com/reference/kotlin/androidx/glance/appwidget/lazy/LazyItemScope)`.(index: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, item) `->` `[Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | the content displayed by a single item                                                                                                                                                                                                                                                  |