Hey I have two questions about the LazyVerticalGri...
# compose-desktop
j
Hey I have two questions about the LazyVerticalGrid. I have this grid:
Copy code
LazyVerticalGrid(
        columns = GridCells.Adaptive(246.dp),
        contentPadding = PaddingValues(
            start = 12.dp,
            top = 16.dp,
            end = 12.dp,
            bottom = 16.dp
        ),
        content = {
            items(result.size) { index ->
                //draw item
            }
        }
    )
}
Now the scroll state of the grid is always like in the end or in the middle so it doen't start at the top and I don't know why. Also how to save the scroll state when the lazyverticalgrid leaves the composition?
d
Create state
Copy code
val state = rememberLazyGridState()
Pass the state:
Copy code
LazyVerticalGrid(
        state = state,
        columns = GridCells.Adaptive(246.dp),
        contentPadding = PaddingValues(
            start = 12.dp,
            top = 16.dp,
            end = 12.dp,
            bottom = 16.dp
        ),
        content = {
            items(result.size) { index ->
                //draw item
            }
        }
    )
}
now you will keep the same state through recompositions