withVoidPointerCallback function

Future<int> withVoidPointerCallback(
  1. void func(
    1. Pointer<NativeFunction<Void Function(Pointer<Void>)>>
    )
)

Implementation

Future<int> withVoidPointerCallback(
    void Function(Pointer<NativeFunction<Void Function(Pointer<Void>)>>)
        func) async {
  JSArray retVal = createVoidPointerCallback();
  var promise = retVal.toDart[0] as JSPromise<JSNumber>;

  var fnPtrAddress = retVal.toDart[1] as JSNumber;
  var fnPtr = Pointer<NativeFunction<Void Function(Pointer<Void>)>>.fromAddress(
      fnPtrAddress.toDartInt);
  func(fnPtr);
  final addr = await promise.toDart;
  return addr.toDartInt;
}