askarEntryListGetValue function

AskarResult<Uint8List> askarEntryListGetValue(
  1. EntryListHandle handle,
  2. int index
)

Implementation

AskarResult<Uint8List> askarEntryListGetValue(EntryListHandle handle, int index) {
  Pointer<NativeSecretBuffer> secretBufferPointer = calloc<NativeSecretBuffer>();

  try {
    final funcResult = nativeAskarEntryListGetValue(
      handle.toInt(),
      index,
      secretBufferPointer,
    );

    final errorCode = ErrorCode.fromInt(funcResult);

    final Uint8List value =
        (errorCode == ErrorCode.success)
            ? secretBufferToBytesList(secretBufferPointer.ref)
            : Uint8List(0);

    return AskarResult<Uint8List>(errorCode, value);
  } finally {
    freeSecretBufferPointer(secretBufferPointer);
  }
}