FLUTTER: WEB
Hello I would like when I click on a button that the function bellow is executed in a non-blocking way and it does not freeze the ui, the problem is by wrapping it in a Future, it freezes the ui, and I even used async_task but it does not work...
List<int> _compressFiles(List<Uint8List> data) {
BZip2Encoder zec = BZip2Encoder();
Archive archive = new Archive();
for (var i = 0; i < data.length; i++) {
archive.addFile(ArchiveFile(i.toString(), data[i].elementSizeInBytes, data[i]));
}
List<int> tar_data = TarEncoder().encode(archive);
List<int> tar_bz2 = BZip2Encoder().encode(tar_data);
return tar_bz2;
}
(This code is using the archive lib https://pub.dev/packages/archive).
onPressed function:
onPressed: () {
//this freeze the ui for 3-4s
List<Uint8List> l = [];
for (var i in list) {
l.add(i.image);
}
compressFiles(l).then(...);
}