title: DART function, nested / inner functions variable
body: <p>I've the below code as anonymous function (also function literal or lambda abstraction), which is used in <a href="https://pub.dartlang.org/packages/mailer" rel="nofollow">DART mailer</a></p>
  
  <pre><code>email(){ 
     ...
     emailTransport.send(envelope)
     .then((success) =&gt; print('Email sent! $success'))
     .catchError((e) =&gt; print('Error occured: $e'));
  }
  </code></pre>
  
  <p>this worked fine, but I need to replace the "print" by a "return" to be like below:</p>
  
  <pre><code>email(){ 
     ...
     emailTransport.send(envelope)
     .then((success) =&gt; return 'Email sent! $success')
     .catchError((e) =&gt; return 'Error occured: $e');
  }
  </code></pre>
  
  <p>but failed, the return had not been recognized!</p>
  
  <p>I tried the below code, but failed too.</p>
  
  <pre><code>email(){ 
     ...
     var msg;
     ...
     emailTransport.send(envelope)
     .then((success) =&gt; msg = 'Email sent! $success')
     .catchError((e) =&gt; msg = 'Error occured: $e');
  
   return msg;
  }
  </code></pre>
  
  <p>But the "msg" remained NULL!</p>
  
  <p>any thoughts.</p>