get method

String get(
  1. int index
)

Gets an item of the StringArray object.

param index Index of the item to get. return item to get. throws BiosealException An error has occurred during Bioseal Library execution.

Implementation

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