From 2b2816de3c358cecc5092035ed313c03c7434b21 Mon Sep 17 00:00:00 2001 From: TapTap Date: Sun, 2 Aug 2026 18:31:22 +0200 Subject: [PATCH] fix: unique keys for LazyRow to prevent crash with duplicate cards --- shared/src/commonMain/kotlin/com/uno/shared/UnoGameScreen.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/shared/src/commonMain/kotlin/com/uno/shared/UnoGameScreen.kt b/shared/src/commonMain/kotlin/com/uno/shared/UnoGameScreen.kt index cca1826..32ee4ac 100644 --- a/shared/src/commonMain/kotlin/com/uno/shared/UnoGameScreen.kt +++ b/shared/src/commonMain/kotlin/com/uno/shared/UnoGameScreen.kt @@ -542,14 +542,15 @@ private fun PlayerHand( horizontalArrangement = Arrangement.spacedBy((-8).dp), contentPadding = PaddingValues(horizontal = 16.dp) ) { - items(player.hand, key = { "${it.color}_${it.value}_${player.hand.indexOf(it)}" }) { card -> + items(player.hand.size) { index -> + val card = player.hand[index] val canPlay = topCard != null && card.canPlayOn(topCard, currentColor) AnimatedCardEntry( card = card, onClick = { onCardClick(card) }, modifier = Modifier.padding(horizontal = 4.dp), isPlayable = canPlay && isCurrentTurn, - animationDelay = player.hand.indexOf(card) * 30 + animationDelay = index * 30 ) } }