Is there a way to know how many columns do we have when using GridCells.Adaptive cells?

Viewed 40

Is there a way to know how many columns do we have when using GridCells.Adaptive cells with LazyVerticalGrid?

1 Answers

As far as I know, the only way currently is to look at maxLineSpan of LazyGridItemScope.

val columnsCount = 0 

item(span = {
    columnsCount = maxLineSpan
    GridItemSpan(maxLineSpan)
}) {
                                        
}

I don't think it's good enough however since I don't want to assign variables and need it outside this scope. And you shouldn't depend on state in one composable from another composable.

Related