Hello I am trying to build a list of items that mi...
# compose
f
Hello I am trying to build a list of items that might be dynamically loaded. Imagine like a chat screen, where some messages might take a bit to load (for example) they are images, so they might expand after they are sent (when the image is finally loaded). I have no problem building this at all, the problem is that i want the focus of the list to always be at the bottom (i have
verticalArrangement = Bottom
, which is where the most recent message is. The problem is that the last message is always slightly cut (like around 24.dp below the input text to send messages on the bottom). Seems like the
LazyColumn
calculates the space to scroll based on the message box original size, but then when the dynamic content is loaded and it expands, it doesn’t readjust. I tried having a
LaunchedEffect
and calculating the last item height (with
onGloballyPositioned
modifier and scroll to the last item with that as
offset
, the problem is that then it doesnt allow me to scroll back to the top 😅. I would have somehow to create a key that would be the combination of two key changes (& rule not or). I can fix this by locking this launched effect based on if there is already a scroll happening, but doesnt seem a good solution. Also everytime i write a message, it focuses on the 1st element of the list, instead of the last. Why ? Does anyone have any idea how can i achieve this ?