withBoolCallback function

Future<bool> withBoolCallback(
  1. dynamic func(
    1. Pointer<NativeFunction<Void Function(Bool)>>
    )
)

Implementation

Future<bool> withBoolCallback(
    Function(Pointer<NativeFunction<Void Function(Bool)>>) func) async {
  JSArray retVal = createBoolCallback();
  var promise = retVal.toDart[0] as JSPromise<JSBoolean>;

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