I have been using LazyColumn to load list of items...
# compose
t
I have been using LazyColumn to load list of items with paging-compose library Here is the code
Copy code
@Composable
fun ListOfItems(pagedItems: Flow<PagingData<Item>>) {
    val items: LazyPagingItems<Item> = pagedItems.collectAsLazyPagingItems()

    LazyColumn {
        items(items) { item ->
            ItemCard(item)
        }
    }
}
Problem is scrolled state is not retained when the screen is rotated Tried with the following
Copy code
val listState: LazyListState = rememberSaveable(saver = LazyListState.Saver) { LazyListState() }
val scrollState: ScrollState = rememberSaveable(saver = ScrollState.Saver) { ScrollState(0) }

LazyColumn(
    modifier = Modifier
        .scrollable(scrollState, Orientation.Vertical),
    state = listState,
) {}
Still got no luck
d
If
items
becomes empty the scroll will be reset.