IsolateChannel<T> constructor Null safety

IsolateChannel<T>(
  1. ReceivePort receivePort,
  2. SendPort sendPort
)

Creates a stream channel that receives messages from receivePort and sends them over sendPort.

Implementation

factory IsolateChannel(ReceivePort receivePort, SendPort sendPort) {
  var controller =
      StreamChannelController<T>(allowForeignErrors: false, sync: true);
  receivePort.cast<T>().pipe(controller.local.sink);
  controller.local.stream
      .listen((data) => sendPort.send(data), onDone: receivePort.close);
  return IsolateChannel._(controller.foreign.stream, controller.foreign.sink);
}