{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

LazyStaggeredGridScope

public sealed interface LazyStaggeredGridScope


Receiver scope for LazyVerticalStaggeredGrid and LazyHorizontalStaggeredGrid

Summary

Public methods

abstract void
item(
    Object key,
    Object contentType,
    StaggeredGridItemSpan span,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull LazyStaggeredGridItemScopeUnit> content
)

Add a single item to the staggered grid.

abstract void
items(
    int count,
    Function1<@NonNull Integer, @NonNull Object> key,
    @NonNull Function1<@NonNull IntegerObject> contentType,
    Function1<@NonNull Integer, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull IntegerUnit> itemContent
)

Add a count of items to the staggered grid.

Extension functions

default final void
<T extends Object> LazyStaggeredGridDslKt.items(
    @NonNull LazyStaggeredGridScope receiver,
    @NonNull T[] items,
    Function1<@NonNull item, @NonNull Object> key,
    @NonNull Function1<@NonNull item, Object> contentType,
    Function1<@NonNull item, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull item, Unit> itemContent
)

Add an array of items to the staggered grid.

default final void
<T extends Object> LazyStaggeredGridDslKt.items(
    @NonNull LazyStaggeredGridScope receiver,
    @NonNull List<@NonNull T> items,
    Function1<@NonNull item, @NonNull Object> key,
    @NonNull Function1<@NonNull item, Object> contentType,
    Function1<@NonNull item, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull item, Unit> itemContent
)

Add a list of items to the staggered grid.

default final void
<T extends Object> LazyStaggeredGridDslKt.itemsIndexed(
    @NonNull LazyStaggeredGridScope receiver,
    @NonNull T[] items,
    Function2<@NonNull Integer, @NonNull item, @NonNull Object> key,
    @NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType,
    Function2<@NonNull Integer, @NonNull item, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function3<@NonNull LazyStaggeredGridItemScope, @NonNull Integer, @NonNull item, Unit> itemContent
)

Add an array of items with index-aware content to the staggered grid.

default final void
<T extends Object> LazyStaggeredGridDslKt.itemsIndexed(
    @NonNull LazyStaggeredGridScope receiver,
    @NonNull List<@NonNull T> items,
    Function2<@NonNull Integer, @NonNull item, @NonNull Object> key,
    @NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType,
    Function2<@NonNull Integer, @NonNull item, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function3<@NonNull LazyStaggeredGridItemScope, @NonNull Integer, @NonNull item, Unit> itemContent
)

Add a list of items with index-aware content to the staggered grid.

Public methods

item

abstract void item(
    Object key,
    Object contentType,
    StaggeredGridItemSpan span,
    @Composable @ExtensionFunctionType @NonNull Function1<@NonNull LazyStaggeredGridItemScopeUnit> content
)

Add a single item to the staggered grid.

Parameters
Object key

a stable and unique key representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed.

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.

Object contentType

a content type representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible.

StaggeredGridItemSpan span

a custom span for this item. Spans configure how many lanes defined by StaggeredGridCells the item will occupy. By default each item will take one lane.

@Composable @ExtensionFunctionType @NonNull Function1<@NonNull LazyStaggeredGridItemScopeUnit> content

composable content displayed by current item

items

abstract void items(
    int count,
    Function1<@NonNull Integer, @NonNull Object> key,
    @NonNull Function1<@NonNull IntegerObject> contentType,
    Function1<@NonNull Integer, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull IntegerUnit> itemContent
)

Add a count of items to the staggered grid.

Parameters
int count

number of items to add.

Function1<@NonNull Integer, @NonNull Object> key

a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed.

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.

@NonNull Function1<@NonNull IntegerObject> contentType

a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible.

Function1<@NonNull Integer, @NonNull StaggeredGridItemSpan> span

a factory of custom spans for this item. Spans configure how many lanes defined by StaggeredGridCells the item will occupy. By default each item will take one lane.

@Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull IntegerUnit> itemContent

composable content displayed by item on provided position

Extension functions

LazyStaggeredGridDslKt.items

default final void <T extends Object> LazyStaggeredGridDslKt.items(
    @NonNull LazyStaggeredGridScope receiver,
    @NonNull T[] items,
    Function1<@NonNull item, @NonNull Object> key,
    @NonNull Function1<@NonNull item, Object> contentType,
    Function1<@NonNull item, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull item, Unit> itemContent
)

Add an array of items to the staggered grid.

Parameters
@NonNull T[] items

a data array to present

Function1<@NonNull item, @NonNull Object> key

a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed.

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.

@NonNull Function1<@NonNull item, Object> contentType

a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible.

Function1<@NonNull item, @NonNull StaggeredGridItemSpan> span

a factory of custom spans for this item. Spans configure how many lanes defined by StaggeredGridCells the item will occupy. By default each item will take one lane.

@Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull item, Unit> itemContent

composable content displayed by the provided item

LazyStaggeredGridDslKt.items

default final void <T extends Object> LazyStaggeredGridDslKt.items(
    @NonNull LazyStaggeredGridScope receiver,
    @NonNull List<@NonNull T> items,
    Function1<@NonNull item, @NonNull Object> key,
    @NonNull Function1<@NonNull item, Object> contentType,
    Function1<@NonNull item, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull item, Unit> itemContent
)

Add a list of items to the staggered grid.

Parameters
@NonNull List<@NonNull T> items

a data list to present

Function1<@NonNull item, @NonNull Object> key

a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed.

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.

@NonNull Function1<@NonNull item, Object> contentType

a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible.

Function1<@NonNull item, @NonNull StaggeredGridItemSpan> span

a factory of custom spans for this item. Spans configure how many lanes defined by StaggeredGridCells the item will occupy. By default each item will take one lane.

@Composable @ExtensionFunctionType @NonNull Function2<@NonNull LazyStaggeredGridItemScope, @NonNull item, Unit> itemContent

composable content displayed by the provided item

LazyStaggeredGridDslKt.itemsIndexed

default final void <T extends Object> LazyStaggeredGridDslKt.itemsIndexed(
    @NonNull LazyStaggeredGridScope receiver,
    @NonNull T[] items,
    Function2<@NonNull Integer, @NonNull item, @NonNull Object> key,
    @NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType,
    Function2<@NonNull Integer, @NonNull item, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function3<@NonNull LazyStaggeredGridItemScope, @NonNull Integer, @NonNull item, Unit> itemContent
)

Add an array of items with index-aware content to the staggered grid.

Parameters
@NonNull T[] items

a data array to present

Function2<@NonNull Integer, @NonNull item, @NonNull Object> key

a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed.

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.

@NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType

a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible.

Function2<@NonNull Integer, @NonNull item, @NonNull StaggeredGridItemSpan> span

a factory of custom spans for this item. Spans configure how many lanes defined by StaggeredGridCells the item will occupy. By default each item will take one lane.

@Composable @ExtensionFunctionType @NonNull Function3<@NonNull LazyStaggeredGridItemScope, @NonNull Integer, @NonNull item, Unit> itemContent

composable content displayed given item and index

LazyStaggeredGridDslKt.itemsIndexed

default final void <T extends Object> LazyStaggeredGridDslKt.itemsIndexed(
    @NonNull LazyStaggeredGridScope receiver,
    @NonNull List<@NonNull T> items,
    Function2<@NonNull Integer, @NonNull item, @NonNull Object> key,
    @NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType,
    Function2<@NonNull Integer, @NonNull item, @NonNull StaggeredGridItemSpan> span,
    @Composable @ExtensionFunctionType @NonNull Function3<@NonNull LazyStaggeredGridItemScope, @NonNull Integer, @NonNull item, Unit> itemContent
)

Add a list of items with index-aware content to the staggered grid.

Parameters
@NonNull List<@NonNull T> items

a data list to present

Function2<@NonNull Integer, @NonNull item, @NonNull Object> key

a factory of stable and unique keys representing the item. The key MUST be saveable via Bundle on Android. If set to null (by default), the position of the item will be used as a key instead. Using the same key for multiple items in the staggered grid is not allowed.

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.

@NonNull Function2<@NonNull Integer, @NonNull item, Object> contentType

a factory of content types representing the item. Content for item of the same type can be reused more efficiently. null is a valid type as well and items of such type will be considered compatible.

Function2<@NonNull Integer, @NonNull item, @NonNull StaggeredGridItemSpan> span

a factory of custom spans for this item. Spans configure how many lanes defined by StaggeredGridCells the item will occupy. By default each item will take one lane.

@Composable @ExtensionFunctionType @NonNull Function3<@NonNull LazyStaggeredGridItemScope, @NonNull Integer, @NonNull item, Unit> itemContent

composable content displayed given item and index