title: Calling an async method from component constructor in Dart
body: <p>Let's assume that an initialization of MyComponent in Dart requires sending an HttpRequest to the server. Is it possible to construct an object synchronously and defer a 'real' initialization till the response come back?</p>
  
  <p>In the example below, the _init() function is not called until "done" is printed. Is it possible to fix this?</p>
  
  <pre><code>import 'dart:async';
  import 'dart:io';
  
  class MyComponent{
    MyComponent() {
      _init();
    }
  
    Future _init() async {
      print("init");
    }
  }
  
  void main() {
    var c = new MyComponent();
    sleep(const Duration(seconds: 1));
    print("done");
  }
  </code></pre>
  
  <p><strong>Output</strong>:</p>
  
  <pre><code>done
  init
  </code></pre>