I am trying to display paged items using LazyVerticalGrid. The code I am trying is shown below.
val categories = repo.categories.collectAsLazyPagingItems()
LazyVerticalGrid(
cells = GridCells.Fixed(2),
modifier = Modifier.padding(8.dp)
) {
items(categories) { category ->
Box(Modifier.padding(8.dp)) {
CategoryView(category)
}
}
}
Please note that I have imported androidx.paging.compose.items and androidx.paging.compose.collectAsLazyPagingItems. Also categories is of type LazyPagingItems<Category>.
It works perfectly with LazyColumn and LazyRow but not LazyVerticalGrid.
The error I am getting is:
Type mismatch.
Required:
Int
Found:
LazyPagingItems<Category>