title: Good or Bad: Declaring main method async in Dart / Flutter
body: <p>I declare one global variable in the entire app - <code>SharedPreferences prefs</code>, and initialize it in <code>main</code> method.</p>
  
  <p>However, <code>SharedPreferences</code> initialization returns a <code>Future</code> - hence I tried awaiting for it to be resolved in <code>main</code> closure of the app:</p>
  
  <pre class="lang-dart prettyprint-override"><code>SharedPreferences prefs;
  
  void main() async {
    prefs = await SharedPreferences.getInstance();
  
    runApp(MyApp());
  }
  </code></pre>
  
  <p>And it worked well. I currently use this method in my 2 apps in production, and it just occurred to me that making <code>main</code> method asynchronous might not be right.</p>
  
  <p>In the end I have 2 questions:</p>
  
  <ul>
  <li>How does <code>main</code> method gets invoked and how it works in general in Dart / Flutter?</li>
  <li>Will making <code>main</code> method of the app asynchronous bring unexpected behaviour? (it hasn't so far)</li>
  </ul>