I'm working on an app that captures and processes an image. A simplified version of the code is:
build() {
return FloatingActionButton(
onPressed: processImage,
child: Icon(
Icons.camera_alt,
color: color,
),
);
}
processImage(Camera image) async {
await image.process();
}
And in another class:
Future<image> process() {
return Future(() {
for (int x = 0; x < width; x++) {
for (int y = 0; y < height; y++) {
//process image
}
}
});
}
But when process()
is running, the UI freezes.
Why is this happening? Isn't that function passed to Future constructor running in the background?