title: Async/Await/then in Dart/Flutter
body: <p>I have a flutter application where I am using the SQFLITE plugin to fetch data from SQLite DB. Here I am facing a weird problem.  As per my understanding, we use either async/await or then() function for async programming. 
  Here I have a db.query() method which is conducting some SQL queries to fetch data from the DB. After this function fetches the data, we do some further processing in the .then() function. However, in this approach, I was facing some issues.  From where I am calling this getExpensesByFundId(int fundId)function, it doesn't seem to fetch the data properly. It's supposed to return Future> object which will be then converted to List when the data is available. But when I call it doesn't work.</p>
  
  <p>However, I just did some experimentation with it and added "await" keyword in front of the db.query() function and somehow it just started to work fine.  Can you explain why adding the await keyword is solving this issue? I thought when using .then() function, we don't need to use the await keyword.</p>
  
  <p>Here are my codes:  </p>
  
  <pre><code>Future&lt;List&lt;Expense&gt;&gt; getExpensesByFundId(int fundId) async {
      Database db = await database;
  
      List&lt;Expense&gt; expenseList = List();
  
     // The await in the below line is what I'm talking about
  
      await db.query(expTable,where: '$expTable.$expFundId = $fundId')
          .then((List&lt;Map&lt;String,dynamic&gt;&gt; expList){
        expList.forEach((Map&lt;String, dynamic&gt; expMap){
          expenseList.add(Expense.fromMap(expMap));
        });
      });
      return expenseList;
    }
  </code></pre>