title: async/await - not waiting before future() - Dart
body: <p>Based on Dart official page When using <a href="https://www.dartlang.org/tutorials/language/futures#async-await" rel="nofollow noreferrer">Async/Wait</a>:   </p>
  
  <p>When the app sees the word <code>async</code> it execute the function normally synchronously, until it sees <code>await</code> or <code>return</code>  </p>
  
  <blockquote>
    <p>Note that an async function starts executing right away
    (synchronously). The function suspends execution and returns an
    uncompleted future when it reaches the first occurrence of any of the
    following:</p>
    
    <ul>
    <li>The function’s first await expression (after the function gets the
    uncompleted future from that expression). </li>
    <li>Any return statement in the function. </li>
    <li>The end of the function body.</li>
    </ul>
  </blockquote>
  
  <p>and when it sees any of them it returns an uncompleted  <code>Future</code> and stops executing the <code>async</code> function until it execute all of the other functions, and when all of the other functions are executed, the app goes back to the <code>async</code> function and executes what's inside of it.  </p>
  
  <p>Here's a photo from the Dart official page explaining it in more details:<br>
  <a href="https://i.stack.imgur.com/N2h2p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N2h2p.png" alt="Dart Image"></a></p>
  
  <p><strong>But when I was testing that I tried to add a <code>print</code> statement before returning the future result as you can see in the below code, but the result wasn't as stated in the site, as it's saying that the app stops executing once it sees the word <code>await</code>but the statement: <em>"Async - Hi Called 1st"</em> was printed as you can see before the other functions were executed.</strong> </p>
  
  <pre><code>import 'dart:async';
  
  Future&lt;void&gt; print1stAsync() async {
    var test = await callAsync();
    print(test);
  }
  
  main() {
    print1stAsync();
    print2nd();
    print3rd();
    print4th();
  }
  
  print2nd() {
    print('Called 2nd');
  }
  
  print3rd() {
    print("Called 3rd");
  }
  
  print4th() {
    print('Called 4th');
  }
  
  Future&lt;String&gt; callAsync() {
    print("Async - Hi Called 1st");
      return Future(() =&gt; "Async - Called 1st ");
    }
  </code></pre>
  
  <p>Output: </p>
  
  <pre><code>Async - Hi Called 1st
  Called 2nd
  Called 3rd
  Called 4th
  Async - Called 1st 
  </code></pre>
  
  <p>So why is this happening? have I miss understood something?</p>