callAsync method
Implementation
Future<Uint8List> callAsync(String name, Uint8List payload) async {
final port = ReceivePort();
final args = IsolateArguments(name, payload, port.sendPort);
Isolate.spawn<IsolateArguments>(
callBridge,
args,
onError: port.sendPort,
onExit: port.sendPort,
);
Completer<Uint8List> completer = new Completer();
StreamSubscription? subscription;
subscription = port.listen((message) async {
await subscription?.cancel();
completer.complete(message);
});
return completer.future;
}