initCommunicationPort static method
void
initCommunicationPort()
Initialize port for communication between TaskHandler and UI.
Implementation
static void initCommunicationPort() {
final ReceivePort newReceivePort = ReceivePort();
final SendPort newSendPort = newReceivePort.sendPort;
IsolateNameServer.removePortNameMapping(_kPortName);
if (IsolateNameServer.registerPortWithName(newSendPort, _kPortName)) {
streamSubscription?.cancel();
receivePort?.close();
receivePort = newReceivePort;
streamSubscription = receivePort?.listen((data) {
for (final DataCallback callback in dataCallbacks.toList()) {
callback.call(data);
}
});
}
}