---
title: "LazyListPrefetchStrategy"
description: "Implementations of this interface control which indices of a LazyList should be prefetched
(precomposed and premeasured during idle time) as the user interacts with it.

Implementations should invoke [LazyListPrefetchScope.schedulePrefetch] to schedule prefetches
from the [onScroll] and [onVisibleItemsUpdated] callbacks. If any of the returned PrefetchHandles
no longer need to be prefetched, use [LazyLayoutPrefetchState.PrefetchHandle.cancel] to cancel
the request."
type: "interface"
---

<div class='type'>Interface</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>



```kotlin
@ExperimentalFoundationApi
interface LazyListPrefetchStrategy
```


Implementations of this interface control which indices of a LazyList should be prefetched
(precomposed and premeasured during idle time) as the user interacts with it.

Implementations should invoke `LazyListPrefetchScope.schedulePrefetch` to schedule prefetches
from the `onScroll` and `onVisibleItemsUpdated` callbacks. If any of the returned PrefetchHandles
no longer need to be prefetched, use `LazyLayoutPrefetchState.PrefetchHandle.cancel` to cancel
the request.


## Properties

<div class='sourceset sourceset-common'>Common</div>


> **Deprecated** Customization of PrefetchScheduler is no longer supported. LazyLayout will attach an appropriate scheduler internally.

```kotlin
val prefetchScheduler: PrefetchScheduler?
```


A `PrefetchScheduler` implementation which will be used to execute prefetch requests for this
strategy implementation. If null, the default `PrefetchScheduler` for the platform will be
used.



## Functions

```kotlin
fun LazyListPrefetchScope.onScroll(delta: Float, layoutInfo: LazyListLayoutInfo)
```


onScroll is invoked when the LazyList scrolls, whether or not the visible items have changed.
If the visible items have also changed, then this will be invoked in the same frame *after*
`onVisibleItemsUpdated`.

#### Parameters

| | |
| --- | --- |
| delta | the change in scroll direction. Delta < 0 indicates scrolling down while delta > 0 indicates scrolling up. |
| layoutInfo | the current `LazyListLayoutInfo` |



```kotlin
fun LazyListPrefetchScope.onVisibleItemsUpdated(layoutInfo: LazyListLayoutInfo)
```


onVisibleItemsUpdated is invoked when the LazyList scrolls if the visible items have changed.

#### Parameters

| | |
| --- | --- |
| layoutInfo | the current `LazyListLayoutInfo`. Info about the updated visible items can be found in `LazyListLayoutInfo.visibleItemsInfo`. |



```kotlin
fun NestedPrefetchScope.onNestedPrefetch(firstVisibleItemIndex: Int)
```


onNestedPrefetch is invoked when a parent LazyLayout has prefetched content which contains
this LazyList. It gives this LazyList a chance to request prefetch for some of its own
children before coming onto screen.

Implementations can use `NestedPrefetchScope.schedulePrefetch` to schedule child prefetches.
For example, this is useful if this LazyList is a LazyRow that is a child of a LazyColumn: in
that case, `onNestedPrefetch` can schedule the children it expects to be visible when it
comes onto screen, giving the LazyLayout infra a chance to compose these children ahead of
time and reduce jank.

Generally speaking, `onNestedPrefetch` should only request prefetch for children that it
expects to actually be visible when this list is scrolled into view.

#### Parameters

| | |
| --- | --- |
| firstVisibleItemIndex | the index of the first visible item. It should be used to start prefetching from the correct index in case the list has been created at a non-zero offset. |




