remove method Null safety

Piece? remove(
  1. String square
)

Removes a piece from a square and returns it, or null if none is present

Implementation

Piece? remove(String square) {
  Piece? piece = get(square);
  board[SQUARES[square]] = null;
  if (piece != null && piece.type == KING) {
    kings[piece.color] = EMPTY;
  }
  updateSetup(generateFen());
  return piece;
}