canMove method

bool canMove(
  1. Tetromino piece,
  2. BoardState board,
  3. int dRow,
  4. int dCol,
)

True if the piece can move one cell in the given direction.

Implementation

bool canMove(Tetromino piece, BoardState board, int dRow, int dCol) {
  final moved = piece.copyWith(
    position: Position(piece.position.row + dRow, piece.position.col + dCol),
  );
  return !hasCollision(moved, board);
}