title: How to use dispose to prevent memory leak
body: <p>I've this init state method:</p>
  
  <pre><code>@override
    void initState() {
      super.initState();
  
      getNumber(index).then((number) {
        if (number&gt; 1000) {
          number = number/ 1000;
          setState(() {
            flag = true;
            _num = number.toInt().toString();
          });
        } else {
          setState(() {
            _num = number.toInt().toString();
          });
        }
      });
    }
  </code></pre>
  
  <p>And i got this error:</p>
  
  <blockquote>
    <p>This error happens if you call setState() on a State object for a
    widget that no longer appears in the widget tree (e.g., whose parent
    widget no longer includes the widget in its build). This error can
    occur when code calls setState() from a timer or an animation
    callback. The preferred solution is to cancel the timer or stop
    listening to the animation in the dispose() callback. Another solution
    is to check the "mounted" property of this object before calling
    setState() to ensure the object is still in the tree.</p>
    
    <p>This error might indicate a memory leak if setState() is being called
    because another object is retaining a reference to this State object
    after it has been removed from the tree. To avoid memory leaks,
    consider breaking the reference to this object during dispose().</p>
  </blockquote>
  
  <p>How i use dispose  in the right way?</p>