addNFTTransfer method Null safety

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

Add a NFT transfer to the transaction @param {String | Uint8List} to Address of the recipient (hexadecimal or binary buffer) @param {double} amount Amount of UCO to transfer @param {String | Uint8List} nftAddress Address of NFT to spend (hexadecimal or binary buffer)

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";
    }
  }
  final NftTransfer nftTransfer = NftTransfer();
  nftTransfer.to = to;
  nftTransfer.amount = amount;
  nftTransfer.nft = nftAddress;
  data!.ledger!.nft!.transfers!.add(nftTransfer);
  return this;
}