addAuthorizedKey method Null safety

TransactionBuilder addAuthorizedKey(
  1. dynamic publicKey,
  2. dynamic encryptedSecretKey
)

Implementation

TransactionBuilder addAuthorizedKey(publicKey, encryptedSecretKey) {
  if (!(publicKey is Uint8List) && !(publicKey is String)) {
    throw "'publicKey' must be a string or Uint8List";
  }

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

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

  if (encryptedSecretKey is String) {
    if (isHex(encryptedSecretKey)) {
      encryptedSecretKey = hexToUint8List(encryptedSecretKey);
    } else {
      throw "'encryptedSecretKey' must be an hexadecimal string";
    }
  }
  this
      .data!
      .keys!
      .authorizedKeys!
      .putIfAbsent(uint8ListToHex(publicKey), () => encryptedSecretKey);

  return this;
}