title: How to draw from async data in dart?
body: <p>Im trying to read a file (async) and return a list of data. Then, I want to draw lines when every given number is line height using CustomPainter (I want to draw multiple lines)</p>
  
  <pre><code>class BarChartPainter extends CustomPainter {
    @override
    paint(Canvas canvas, Size size) {
      final paint = new Paint()
        ..color = AppColors.primaryColor
        ..style = PaintingStyle.fill;
  
      var futurePath = run();
  
      futurePath.then((height) {
        print('1: $height');
        for (var lineHeight in height) {
          print('2: $lineHeight');
          canvas.drawRect(
              new Rect.fromLTWH(1.0, 10.0, 10.0, lineHeight.toDouble()), paint);
        }
      }).catchError((e) =&gt; print(e));
    }
  
    @override
    bool shouldRepaint(BarChartPainter old) =&gt; false;
  }
  </code></pre>
  
  <p>print('1: $height') returns [75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 72, 10, 2, 0, 0, 0, 0, 0, (...), 0, 85, 22, 3, 1]</p>
  
  <p>print('2: $lineHeight') returns 75</p>
  
  <p>drawRect doesn't work. Error is : I/flutter (13751): Object has been disposed.</p>