I am using a BoxWithConstraints inside it a LazyVe...
# compose
e
I am using a BoxWithConstraints inside it a LazyVerticalGrid where the number of items is dynamic based on the available space. My problem is it is drawing items but in cases where my device is a tablet or foldable, it isn't using the maximum available width in the last row of items. Any guess??
Copy code
BoxWithConstraints {
    val audienceHeight = 120.dp
    val audienceWidth = 80.dp
    val padd = 24.dp
    val paddH = 50.dp
    val col = maxWidth.div(audienceWidth + padd).toInt()
    val row = maxHeight.div(audienceHeight + paddH).toInt()
    println("Col $col")
    println("Row $row")
    val itemsToDraw = (col * row)
    viewModel.state.value.itemsToDraw = itemsToDraw

    LazyVerticalGrid(
        verticalArrangement = Arrangement.spacedBy(8.dp),
        horizontalArrangement = Arrangement.spacedBy(8.dp),
        columns = GridCells.Adaptive(120.dp),
        modifier = Modifier
    ) {
        val participantsSize = viewModel.state.value.participantsShown.size
        items(
            viewModel.state.value.participantsShown.subList(
                fromIndex = 0,
                toIndex = minOf(itemsToDraw - 1, participantsSize)
            )
        ) {
            Audience(participant = it)
        }
        item {
            OpenAllParticipants(viewModel = viewModel)
        }
    }
}