WorkerSocket createWorker(WorkerFunction function, { Map<String, dynamic> metadata })

Source

WorkerSocket createWorker(
  WorkerFunction function, {
    Map<String, dynamic> metadata
  }) {
  var receiver = new ReceivePort();
  var socket = new WorkerSocket.master(receiver);
  var errorReceiver = new ReceivePort();
  Isolate.spawn(function, new Worker(receiver.sendPort, metadata), onError: errorReceiver.sendPort).then((x) {
    socket._isolate = x;
  });
  errorReceiver.listen((data){
    logger.severe(data);
  });
  return socket;
}