croupier: Fix a bug with Board when no take target exists
Check if it is null before you add a number to it.
Change-Id: I3d08985b0cb8624fa832884678735c78386f0144
diff --git a/lib/components/board.dart b/lib/components/board.dart
index 6491981..41b072c 100644
--- a/lib/components/board.dart
+++ b/lib/components/board.dart
@@ -261,11 +261,14 @@
double cccSize = sizeRatio * config.width;
HeartsGame game = config.game;
+ List<logic_card.Card> cardsToTake = [];
+ int takeTarget = game.getTakeTarget(playerNumber);
+ if (takeTarget != null) {
+ cardsToTake = game.cardCollections[
+ game.getTakeTarget(playerNumber) + HeartsGame.OFFSET_PASS];
+ }
return new CardCollectionComponent(
- game.cardCollections[
- game.getTakeTarget(playerNumber) + HeartsGame.OFFSET_PASS],
- false,
- CardCollectionOrientation.horz,
+ cardsToTake, false, CardCollectionOrientation.horz,
backgroundColor: Colors.grey[300],
width: cccSize,
widthCard: config.cardWidth / 2,