Hello here. I have implemented paging with compose...
# compose
n
Hello here. I have implemented paging with compose but instead of using LazyColumn, I wish to use a LazyVerticalGrid with two cells each.How do I use lazyPagingItems in LazyVerticalGrid?
Copy code
val lazyPagingNotes = viewModel.notes.collectAsLazyPagingItems()
a
it will be possible with the next release of paging-compose
n
Okay great
a
I meant the one which was released yesterday
k
Hi, were you able to find a solution to this?
I wrote this extension function because I think isn't available yet
Copy code
@ExperimentalFoundationApi
private fun < T : Any> LazyGridScope.itemsIndexed(
    lazyItems: LazyPagingItems<T>,
    itemContent: @Composable LazyGridScope.(index: Int, value: T?) -> Unit
) {
    items(lazyItems.itemCount) { index ->
        itemContent(index, lazyItems.getAsState(index).value)
    }
}
a
yes, you have to write this function manually for now. there is a policy which doesn’t allow paging-compose to use api from other artefact (compose:foundation) marked as experimental. but what I meant is that prior to the latest version this code you wrote wouldn’t work and now it works
🙏 1