build method

NSObject build({
  1. bool keepIsolateAlive = true,
})

Builds the object.

This can be called multiple times to construct multiple object instances that all implement the same protocol methods using the same functions.

Implementation

objc.NSObject build({bool keepIsolateAlive = true}) {
  if (!_built) {
    _builder.registerClass();
    _built = true;
  }

  var disposePort = c.ILLEGAL_PORT;
  if (keepIsolateAlive) {
    late final RawReceivePort keepAlivePort;
    keepAlivePort = RawReceivePort((_) => keepAlivePort.close());
    disposePort = keepAlivePort.sendPort.nativePort;
  }
  return _builder.buildInstance(disposePort);
}