更换 key

This commit is contained in:
2024-09-17 16:35:06 +08:00
parent 2c3e205441
commit 45fc37e223

View File

@@ -39,6 +39,7 @@ import androidx.compose.ui.zIndex
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.channels.Channel import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import java.util.UUID
@OptIn(ExperimentalFoundationApi::class) @OptIn(ExperimentalFoundationApi::class)
@@ -65,7 +66,7 @@ fun <T : Any> DraggableGrid(
horizontalArrangement = Arrangement.spacedBy(16.dp), horizontalArrangement = Arrangement.spacedBy(16.dp),
) { ) {
itemsIndexed(items, key = { _, item -> item }) { index, item -> itemsIndexed(items, key = { _, item -> "${item}-${UUID.randomUUID()}" }) { index, item ->
DraggableItem(dragDropState, index) { isDragging -> DraggableItem(dragDropState, index) { isDragging ->
content(item, isDragging) content(item, isDragging)
} }