to the top whenever the list size changes. This works great, but it also scrolls the list to the top whenever I navigate back to it since the LaunchedEffect is restarted. I could work around this with
rememberSaveable
, but that doesnt seem ideal. Is there another better approach?
a
Albert Chang
09/09/2022, 10:32 AM
Does the
list
instance change? If it doesn't change, you can use something like:
starts anew everytime the screen re-enters the composition (e.g. when navigating back to it).
a
Albert Chang
09/09/2022, 10:34 AM
That's why I'm using
drop(1)
.
z
Zoltan Demant
09/09/2022, 10:35 AM
Ooooooh. Hmm, let me play around with it a bit! In the meantime, heres what I put together to solve it as well (your solution looks way better though).
Yeah, that works too! 👍🏽 Im pretty sure its the better approach out of the two as well, theres really no need to save any values outside the composition!
Zoltan Demant
09/09/2022, 10:44 AM
Awesome, I really appreciate the help, thank you! 🙏🏽 Since Ill be using this in quite a few spots I put this together: