'LazyColumn - How do you display the most recent item in LazyColumn?
I have a LazyColumn where the use inputs items into. I want the LazyColumn to display the most recent item. How do I do this? Right now, LazyColumn is reversed, but doesn't stay scrolled to the top of the list.
Here is my LazyColumn:
val listState = rememberLazyListState()
LazyColumn(
modifier = Modifier
.fillMaxSize()
.padding(16.dp),
reverseLayout = true,
verticalArrangement = Arrangement.Top,
userScrollEnabled = true,
state = listState
) {
items(cardState.size) {}
items(items = getAllData) { card ->
CustomItem(practiceCard = card, navController = navController)
Spacer(Modifier.size(10.dp))
}
And here is the button to add to the list:
cardRepository.allCards.add(
PracticeCard(
viewModel.sentence)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|