ObjCBlock_ffiVoid.fromFunction constructor

ObjCBlock_ffiVoid.fromFunction(
  1. ThermionDartTexture1 lib,
  2. void fn()
)

Creates a block from a Dart function.

This block must be invoked by native code running on the same thread as the isolate that registered it. Invoking the block on the wrong thread will result in a crash.

Implementation

ObjCBlock_ffiVoid.fromFunction(ThermionDartTexture1 lib, void Function() fn)
    : this._(
          lib._newBlock1(
              _dartFuncTrampoline ??= ffi.Pointer.fromFunction<
                          ffi.Void Function(ffi.Pointer<_ObjCBlock>)>(
                      _ObjCBlock_ffiVoid_closureTrampoline)
                  .cast(),
              _ObjCBlock_ffiVoid_registerClosure(() => fn())),
          lib);