I have column with items where with "swipe-to-dismiss" functionality. The problem is: "swipe-to-delete" removes correct item only first time. Next time it sends wrong id to the "removeTask" function. I fixed it when using lazyColumn by adding item key to the lazyLayout. But for some reason I need to use column.
Column(
modifier = Modifier
.fillMaxWidth()
) {
items.forEach {
SwipeableCompletedTask(task, removeTask)
}
}
@Composable
private fun SwipeableCompletedTask(task: UnboxingTask, removeTask: (String) -> Unit) {
val dismissState = rememberDismissState(
confirmStateChange = {
if (it == DismissValue.DismissedToEnd || it == DismissValue.DismissedToStart) {
removeTask(task.id ?: "") // same id here every time
}
false
}
)
SwipeToDismiss(
state = dismissState,
..........
)
}
How can I fix this?