GlideLazyListPreloader

fun <DataTypeT : Any> GlideLazyListPreloader(    state: LazyListState,     data: List<DataTypeT>,     size: Size,     numberOfItemsToPreload: Int,     fixedVisibleItemCount: Int? = null,     requestBuilderTransform: PreloadRequestBuilderTransform<DataTypeT>)

Preloads ahead of the users current scroll position for LazyRow and androidx.compose.foundation.lazy.LazyColumn, similar to ListPreloader and com.bumptech.glide.integration.recyclerview.RecyclerViewPreloader.

The only time this API is useful is when your UI also loads an item with exactly the same options, model and size. Be careful to make sure that your requests are identical in the preloader and in the UI, or you might end up hurting performance instead of improving it.

Parameters

state

The LazyListState provided to the LazyRow or LazyColumn

data

The backing list of metadata that we're going to preload images for.

size

The override size we'll pass to RequestBuilder.override .

numberOfItemsToPreload

The number of items to preload ahead of the user's current position. This should be tested for each application. If the total memory size of the preloaded images exceeds the memory cache size, preloading for a lazy list is not effective. However if you preload too few things, the buffer may be small enough that images are not available when they could be, so it's always a balancing act. The smaller the preloaded image, the more you can preload.

fixedVisibleItemCount

The number of visible items. In some cases this can vary widely in which case you can leave this value null. If the number of visible items is always one or two, it might make sense to just set this to the larger of the two to reduce churn in the preloader.