buildMove method Null safety

Move buildMove(
  1. List<Piece?> board,
  2. dynamic from,
  3. dynamic to,
  4. dynamic flags,
  5. [PieceType? promotion]
)

Implementation

Move buildMove(List<Piece?> board, from, to, flags, [PieceType? promotion]) {
  if (promotion != null) {
    flags |= BITS_PROMOTION;
  }
  PieceType? captured;
  Piece? toPiece = board[to];
  if (toPiece != null) {
    captured = toPiece.type;
  } else if ((flags & BITS_EP_CAPTURE) != 0) {
    captured = PAWN;
  }
  return Move(
      color: turn,
      from: from,
      to: to,
      flags: flags,
      piece: board[from]!.type,
      captured: captured,
      promotion: promotion);
}