Flutter: Unblocking UI thread with Isolates compute function
In this post I will show you, how to use compute function from the Flutter framework to push CPU-heavy computation from main thread (which does the UI stuff) to another thread. This will unlock the main thread and your application will be responsive...
gladimdim.org
I do something different which is exporting the created pdf into png files which takes a heavy toll on the main thread. Do you know if there is a way to compute the below?
if (!isPdf) { int pageIndex = 1; await for (var page in Printing.raster(pdf.save(), dpi: 300)) { final image = await page.toPng(); final String pageQty = (pagesToPrint > 1) ? '$pageIndex-$pagesToPrint' : '1-1'; file = File("${output.path}/$fileName--$pageQty.png"); await file.writeAsBytes(image); imageList.add(file); pageIndex++; } } else { file = File("${output.path}/$fileName.pdf"); await file.writeAsBytes(pdf.save()); imageList.add(file); }