getBinaryAtIndex method

Uint8List getBinaryAtIndex(
  1. int index
)

Gets the binary data at the specified index.

param index The index of the binary field to retrieve. return The binary data. throws BiosealException An error has occurred during Bioseal Library execution.

Implementation

Uint8List getBinaryAtIndex(int index) {
  Pointer<UnsignedChar> pItem = nullptr;
  Pointer<Int> pItemSize = calloc();
  pItemSize[0] = -1;
  try {
    var err = biosealSDK.id3BiosealField_GetBinaryAtIndex(_pHandle.value, index, pItem, pItemSize);
    if (err == BiosealError.insufficientBuffer.value) {
      pItem = calloc.allocate(pItemSize.value);
      err = biosealSDK.id3BiosealField_GetBinaryAtIndex(_pHandle.value, index, pItem, pItemSize);
    }
    if (err != BiosealError.success.value) {
      throw BiosealException(err);
    }
    final vItem = Uint8List.fromList(pItem.cast<Uint8>().asTypedList(pItemSize.value));
    return vItem;
  } finally {
    calloc.free(pItem);
    calloc.free(pItemSize);
  }
}