get method

String get(
  1. int index
)

Gets an item of the StringList object.

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

Implementation

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