copyWith method

GameState copyWith({
  1. BoardState? board,
  2. Tetromino? activePiece,
  3. Tetromino? ghostPiece,
  4. Tetromino? heldPiece,
  5. bool? canHold,
  6. List<TetrominoType>? nextQueue,
  7. ScoreState? scoreState,
  8. LevelState? levelState,
  9. TetrisGameStatus? status,
  10. bool clearActive = false,
  11. bool clearGhost = false,
  12. bool clearHeld = false,
})

Implementation

GameState copyWith({
  BoardState? board,
  Tetromino? activePiece,
  Tetromino? ghostPiece,
  Tetromino? heldPiece,
  bool? canHold,
  List<TetrominoType>? nextQueue,
  ScoreState? scoreState,
  LevelState? levelState,
  TetrisGameStatus? status,
  bool clearActive = false,
  bool clearGhost = false,
  bool clearHeld = false,
}) =>
    GameState(
      board: board ?? this.board,
      activePiece: clearActive ? null : activePiece ?? this.activePiece,
      ghostPiece: clearGhost ? null : ghostPiece ?? this.ghostPiece,
      heldPiece: clearHeld ? null : heldPiece ?? this.heldPiece,
      canHold: canHold ?? this.canHold,
      nextQueue: nextQueue ?? this.nextQueue,
      scoreState: scoreState ?? this.scoreState,
      levelState: levelState ?? this.levelState,
      status: status ?? this.status,
    );