Hello all, having trouble wrapping my head around ...
# compose
b
Hello all, having trouble wrapping my head around an infinite lazycolumn using the pager v3 library. I would like to scroll up infinitely as new “un-viewed” items are available. This means that on initial load of the view, I would like to start the user at the bottom of the list, not the top.
Currently I am scrolling to the last item a user has viewed, in the case of never viewed I start them at the bottom. To do both scrolls I am using:
Copy code
val listState = rememberLazyListState()
listState.scrollToItem(index)
However I think that is pretty inefficient on first load, or a load with a lot of un-viewed items. Assuming that scrollToItem(index) is loading each item as it scrolls.
d
rememberLazyListState takes index of the item that should be visible
i
Generally, that's the use case for LazyColumn's
reverseLayout
, which starts you at the bottom and you scroll up to view more
☝️ 1
b
@dorche thanks, missed that. Guess I need some sleep ;). Ian agreed, I just saw that option messing around with it now. Seems that in combination with constructing the list state with the right index is the way to go.