refactor: replace await for loop with listen for message handling

This commit is contained in:
Moustapha Kodjo Amadou 2025-11-25 15:35:29 +01:00
parent 405c3d8e35
commit 26362fe556

View file

@ -68,8 +68,7 @@ class ImageCropIsolate {
final receivePort = ReceivePort();
mainSendPort.send(receivePort.sendPort);
await for (var message in receivePort) {
receivePort.listen((message) async {
if (message is Map<String, dynamic>) {
try {
final imageBytes = message['imageBytes'] as Uint8List;
@ -84,9 +83,9 @@ class ImageCropIsolate {
}
} else if (message == 'dispose') {
RustLib.dispose();
break;
receivePort.close();
}
}
});
}
Future<Uint8List?> process(Uint8List imageBytes) async {