getUrl method

String getUrl(
  1. Uint8List? lotlData,
  2. String? manifestId,
  3. String? iac
)

Returns the URL to the TSL or the next LoTL.

param lotlData The LotL data. param manifestId The Manifest ID in ISO 22385 format (hexadecimal string). param iac The IAC (optional). return The TSL url. throws BiosealException An error has occurred during Bioseal Library execution.

Implementation

String getUrl(Uint8List? lotlData, String? manifestId, String? iac) {
  Pointer<UnsignedChar>? pLotlData;
  if (lotlData != null) {
  	pLotlData = calloc.allocate<UnsignedChar>(lotlData.length);
  	pLotlData.cast<Uint8>().asTypedList(lotlData.length).setAll(0, lotlData);
  }
  Pointer<Char>? pManifestId = manifestId?.toNativeUtf8().cast<Char>();
  Pointer<Char>? pIac = iac?.toNativeUtf8().cast<Char>();
  Pointer<Char> pUrl = nullptr;
  Pointer<Int> pUrlSize = calloc.allocate(1);
  pUrlSize[0] = -1;
  try {
    var err = biosealSDK.id3BiosealLotl_GetUrl(_pHandle.value, pLotlData ?? nullptr, lotlData?.length ?? 0, pManifestId ?? nullptr, pIac ?? nullptr, pUrl, pUrlSize);
    if (err == BiosealError.insufficientBuffer.value) {
      pUrl = calloc.allocate(pUrlSize.value);
      err = biosealSDK.id3BiosealLotl_GetUrl(_pHandle.value, pLotlData ?? nullptr, lotlData?.length ?? 0, pManifestId ?? nullptr, pIac ?? nullptr, pUrl, pUrlSize);
      if (err != BiosealError.success.value) {
        throw BiosealException(err);
      }
    }
    final vUrl = utf8.decode(Uint8List.fromList(pUrl.cast<Uint8>().asTypedList(pUrlSize.value)));
    return vUrl;
  } finally {
    if (pLotlData != null) {
      calloc.free(pLotlData);
    }
    if (pManifestId != null) {
      calloc.free(pManifestId);
    }
    if (pIac != null) {
      calloc.free(pIac);
    }
    calloc.free(pUrl);
    calloc.free(pUrlSize);
  }
}