withVoidCallback function

Future<void> withVoidCallback(
  1. dynamic func(
    1. Pointer<NativeFunction<Void Function()>>
    )
)

Implementation

Future<void> withVoidCallback(
    Function(Pointer<NativeFunction<Void Function()>>) func) async {
  JSArray retVal = createVoidCallback();
  var promise = retVal.toDart[0] as JSPromise<JSNumber>;
  var fnPtrAddress = retVal.toDart[1] as JSNumber;
  var fnPtr = Pointer<NativeFunction<Void Function()>>.fromAddress(
      fnPtrAddress.toDartInt);
  func(fnPtr);
  await promise.toDart;
}