title: Flutter- compute method
body: <p>I'm trying to execute heavy method by <code>compute()</code>.<br>
  I tried like so. 
  After <code>loop</code> executed, <code>Text</code> widget update but <code>result</code> returns 0 almost right after button was pressed.<br>
  Does anyone know what am I missing? </p>
  
  <pre><code> int _counter;
  
    static int loop(int val) {
      int count = 0;
      for (int i = 1; i &lt;= val; i++) {
        count += i;
      }
      return count;
    }
  
    Future&lt;void&gt; _onPressed() async {
      int result = await compute(loop, 1000000000000000000);
      setState(() {
        _counter = result;
      });
    }
  </code></pre>