https://kotlinlang.org logo
#compose
Title
# compose
t

TheDukerChip

07/19/2021, 6:59 PM
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

Dominaezzz

07/19/2021, 8:32 PM
If
items
becomes empty the scroll will be reset.
7 Views