I'm working on an image processing app. I have an animated gif to show progress. As Dart is a single thread, every time the image is being processed, it locks UI, including the animated gif. I don't want to use isolates to avoid potential memory leaks. I want to implement something using event loop, similar to the link below.
https://hackernoon.com/executing-heavy-tasks-without-blocking-the-main-thread-on-flutter-6mx31lh
I have tried to insert some delay during pixel looping as suggested in this thread but it doesn't work.
Dart future blocking main thread
Future<image> process2() {
return Future(() async {
for (var x = 0; x < width; x++) {
for (var y = 0; y < height; y++) {
// process
}
if (x % 100 == 0) {
await Future.delayed(Duration(seconds: 100));
}
}
});
}