Question: What's the best way to keep a vertically...
# compose-desktop
k
Question: What's the best way to keep a vertically scrollable Text object, whose content is always added to, always scrolled to the bottom by default? Thanks!
👀 2
t
You mean something like a Chat window ?
k
Yes, mate thanks.
Specifically a Serial Monitor window, which I have sorta working now!
t
You can use a
LaunchedEffect
like this, right?
Copy code
val list = remember { mutableStateListOf<String>("A") }
val listState = rememberLazyListState()
LaunchedEffect(list.size) {
    listState.animateScrollToItem(list.lastIndex)
}
full code : https://gist.github.com/theapache64/275553a0fa320227693dc4998b13dab0
👌 1
If you don’t have a
LazyRow/Column/Grid
, you can modify it something like
LaunchedEffect(myText.size)
and fire a scroll to bottom event ?
k
Ok! Thanks mate, I'll look into that. 😎👍