addNFTTransfer method Null safety

TransactionBuilder addNFTTransfer(
  1. dynamic to,
  2. double amount,
  3. dynamic nftAddress
)

Implementation

TransactionBuilder addNFTTransfer(to, double amount, nftAddress) {
  if (!(to is Uint8List) && !(to is String)) {
    throw "'to' must be a string or Uint8List";
  }

  if (to is String) {
    if (isHex(to)) {
      to = hexToUint8List(to);
    } else {
      throw "'to' must be an hexadecimal string";
    }
  }

  if (!(nftAddress is Uint8List) && !(nftAddress is String)) {
    throw "'nftAddress' must be a string or Uint8List";
  }

  if (nftAddress is String) {
    if (isHex(nftAddress)) {
      nftAddress = hexToUint8List(nftAddress);
    } else {
      throw "'nftAddress' must be an hexadecimal string";
    }
  }
  NftTransfer nftTransfer = new NftTransfer();
  nftTransfer.to = to;
  nftTransfer.amount = amount;
  nftTransfer.nft = nftAddress;
  this.data!.ledger!.nft!.transfers!.add(nftTransfer);
  return this;
}