addUCOTransfer method Null safety

TransactionBuilder addUCOTransfer(
  1. dynamic to,
  2. double amount
)

Implementation

TransactionBuilder addUCOTransfer(to, double amount) {
  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";
    }
  }
  UcoTransfer ucoTransfer = new UcoTransfer();
  ucoTransfer.to = to;
  ucoTransfer.amount = amount;
  this.data!.ledger!.uco!.transfers!.add(ucoTransfer);
  return this;
}