title: Flutter - Compute: Illegal argument in isolate message : (object is a closure - Function '<anonymous closure>':.)
body: <p>I am trying to unzip a file with compute as follows.</p>
  <pre><code>class FileDownloader{
  
    void downloadCompleteZip(Function(double) listenerFunction){
        Map&lt;String, dynamic&gt; map = {
          'fileRoot': localPath,
          &quot;filePath&quot;: completeZipLocalPath,
          &quot;listener&quot;: listenerFunction,
          &quot;unzipPerc&quot;: unzipPerc
        };
  
        await compute(unzipCompleteZipToDisk, map);
    }
  }
  void unzipCompleteZipToDisk(Map&lt;String, dynamic&gt; params) async {}
  </code></pre>
  <p>When i call the downloadCompleteZip function i get the following error:</p>
  <blockquote>
  <p>Invalid argument(s): Illegal argument in isolate message : (object is
  a closure - Function '':.)</p>
  </blockquote>
  <p>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:</p>
  <pre><code>&quot;listener&quot;: listenerFunction,
  </code></pre>
  <p>My <em><strong>downloadCompleteZip</strong></em> function is longer, for the sake of example i simplified it. I really need to pass the <em><strong>listener</strong></em> 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?</p>
  <p>Also, kindly please dont suggest third party lib solutions. I have seen that libs like <a href="https://pub.dev/packages/isolate" rel="nofollow noreferrer">this can help.</a> I am trying to keep 3rd party dependencies as low as possible.</p>