compressImagesInParallel method
Implementation
Future<Uint8List> compressImagesInParallel(Uint8List inputData, int maxSizeInBytes) async {
final receivePort = ReceivePort();
final completer = Completer<Uint8List>();
await Isolate.spawn(_compressorIsolate, receivePort.sendPort);
receivePort.listen((message) {
if (message is SendPort) {
message.send([inputData, maxSizeInBytes]);
} else if (message is Uint8List) {
completer.complete(message);
}
});
final compressedImageBytes = await completer.future;
receivePort.close();
return compressedImageBytes;
}