childrenIndexed

fun <T> childrenIndexed(items: Iterable<T>, id: (Int, T) -> Any, isSticky: IndexedPredicate<T>? = null, parentWidthPercent: IndexedFloatMapper<T>? = null, parentHeightPercent: IndexedFloatMapper<T>? = null, componentFunction: ComponentCreationScope.(Int, T) -> Component?)

Add a list of children generated by applying componentFunction to each item in a list of models, providing the index of each item.

This is the indexed variant of children, useful for patterns like spacer-before where the first item needs special handling, or when the child id needs to incorporate position. Prefer this over manual forEachIndexed { ... child() } loops for better diffing — see R27.

Parameters

items

Data models to be rendered as children

id

A function to create a unique id from index and data model

isSticky

A function that indicates if the child should fix to the top of the collection when it is scrolled out of view

parentWidthPercent

A function that sets the fill width of the child based on the parent container's size

parentHeightPercent

A function that sets the fill height of the child based on the parent container's size

componentFunction

A function that generates a Component from index and data model


fun <T> childrenIndexed(items: Iterable<T>, id: (Int, T) -> Any, deps: (Int, T) -> Array<Any?>, isSticky: IndexedPredicate<T>? = null, parentWidthPercent: IndexedFloatMapper<T>? = null, parentHeightPercent: IndexedFloatMapper<T>? = null, componentFunction: ComponentCreationScope.(Int, T) -> Component?)

Add a list of children generated by applying componentFunction to each item in a list of models, providing the index of each item.

Parameters

items

Data models to be rendered as children

id

A function to create a unique id from index and data model

deps

A function to create a list of deps from index and data model

isSticky

A function that indicates if the child should fix to the top of the collection when it is scrolled out of view

parentWidthPercent

A function that sets the fill width of the child based on the parent container's size

parentHeightPercent

A function that sets the fill height of the child based on the parent container's size

componentFunction

A function that generates a Component from index and data model