getMethodName method Null safety

String getMethodName()

Get a method name.
return - The name of the method that created this template.

Implementation

String getMethodName() {
  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 templateSave = _dll_handle.lookupFunction<_Template_get_method_name_c, _Template_get_method_name_dart>(_c_namespace + 'Template_getMethodName');

  var exception = _getException();
  templateSave(_impl, _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);
}