getVersion method Null safety

String getVersion()

Implementation

String getVersion() {
  Pointer<Pointer<Uint8>> _emptyPointerList = malloc.allocate(sizeOf<Pointer<Pointer<Uint8>>>() * 2);
  _emptyPointerList[0] = malloc.allocate(sizeOf<Pointer<Int32>>());
  _emptyPointerList[1] = malloc.allocate(1000);

  Pointer<Int32> byteCount = Pointer.fromAddress(_emptyPointerList[0].address);
  byteCount.value = 0;

  final getVersion = _dll_handle.lookupFunction<_get_version_c, _get_version_dart>(_c_namespace + 'get_version');

  var exception = _getException();
  getVersion(_emptyPointerList.cast(), Pointer.fromFunction(writeFunc), exception);
  checkException(exception, _dll_handle);

  List<int> result = [];
  for (var i = 0; i < byteCount.value; i++) {
    result.add(_emptyPointerList[1][i]);
  }
  malloc.free(_emptyPointerList[0]);
  malloc.free(_emptyPointerList[1]);
  malloc.free(_emptyPointerList);

  return utf8.decode(result);
}