title: returning a value in sync and await in dart
body: <p>I am trying to understand the usage of async and await in Dart. Somehow I am having issues returning values in certain methods.</p>
  
  <p>Consider the code below</p>
  
  <pre><code>Future&lt;int&gt; getMrn() async {
    var mrnRef = await firebaseClient.child('mrn');
  
    DataSnapshot ss;
    StreamSubscription&lt;Event&gt; onValueSubscription = await mrnRef.onValue
        .listen((event) {
      ss = event.snapshot;
  
      return ss.val();
    });
  
    //return Future&lt;int&gt; ss.val();
  }
  </code></pre>
  
  <p><code>mrn</code> is of type <code>int</code> which should be returned by <code>getMrn</code> method. However each time the returned <code>ss.val()</code> returns <code>null</code>. It seems that <code>ss = event.snapshot</code> is not seen in the last returned value</p>
  
  <p>What is the correct way of doing this.
  Thanks</p>