Couldn't find a composable to create grid lists so...
# compose
s
Couldn't find a composable to create grid lists so this is what I ended up with:
Copy code
@Composable
fun <T> LazyGridFor(
    items: List<T> = listOf(),
    cols: Int = 3,
    modifier: Modifier = Modifier,
    contentPadding: InnerPadding = InnerPadding(0.dp),
    horizontalGravity: Alignment.Horizontal = Alignment.Start,
    itemContent: @Composable LazyItemScope.(T) -> Unit
) {
    val chunkedList = items.chunked(cols)
    LazyColumnFor(
        items = chunkedList,
        modifier = modifier,
        contentPadding = contentPadding,
        horizontalGravity = horizontalGravity
    ) {
        Row {
            for(item in it) {
                Box(Modifier.weight(1f)) {
                    itemContent(item)
                }
            }
        }
    }
}
So far I haven't experienced any problems with this. Is there any other way for lazy grids tho? Edit: I think there's a little stuttering while scrolling the list but I've only experienced it a couple of times.
👍 2