Source
WorkerSocket createFakeWorker(WorkerFunction function, {Map<String, dynamic> metadata}) { var receiver = new ReceivePort(); var socket = new WorkerSocket.master(receiver); Timer.run(() { var w = new Worker(receiver.sendPort, metadata); w._master = socket; function(w); }); return socket; }