I am trying to unzip a file with compute as follows.
class FileDownloader{
void downloadCompleteZip(Function(double) listenerFunction){
Map<String, dynamic> map = {
'fileRoot': localPath,
"filePath": completeZipLocalPath,
"listener": listenerFunction,
"unzipPerc": unzipPerc
};
await compute(unzipCompleteZipToDisk, map);
}
}
void unzipCompleteZipToDisk(Map<String, dynamic> params) async {}
When i call the downloadCompleteZip function i get the following error:
Invalid argument(s): Illegal argument in isolate message : (object is a closure - Function '':.)
My types for variables in map are, String and Function. I think the problem is that im trying to pass a function inside map here:
"listener": listenerFunction,
My downloadCompleteZip function is longer, for the sake of example i simplified it. I really need to pass the listener key as it sends messages to update UI. How may i solve this issue of functions not being able to pass within a map inside compute?
Also, kindly please dont suggest third party lib solutions. I have seen that libs like this can help. I am trying to keep 3rd party dependencies as low as possible.