Can someone share insights on how to use
rememberLazyListState
with
LazyColumn
for a chat interface? JetChat in
compose-samples
still uses
ScrollableColumn
so it doesn’’t help much, especially in these areas:
• How do we smooth scroll to show a new incoming message? Since we only have relative-based
smoothScrollBy
instead of
smoothScrollTo(0f)
(on
reverseLayout = true
), it’s hard to get to the right spot and
snapToIndex(0)
is unnatural
• How do we get measurements of the specific message component sizes to make the right relative scrolling calculation? I’ve seen
chatScrollState.layoutInfo.visibleItemsInfo
but i’m not sure how to get updates when
layoutInfo
changes, sticking it inside
LaunchedEffect
doesn’t fire
• How do we know when we are getting to the end of the
LazyColumn
so that we can fetch older messages and add them to the list?
• In the case where new messages are coming in or old messages are being added, how do we maintain existing scroll position without the whole list jumping around?