title: Flutter: The method forEach isn't defined for the class DataSnapshot
body: <p>I need to iterate a node in a <code>DatabaseReference</code> in firebase. But it is wired that there is no <code>forEach</code> function in <code>DataSnapshot</code> that is in <code>firebase_database</code> library!</p>
  
  <p>I also tried to use <code>DataSnapshot</code> object that is in <code>firebase</code> library (that has a forEach function in it) but I got a error:</p>
  
  <pre><code>[dart] The argument type '(DataSnapshot) → List&lt;dynamic&gt;' can't be assigned to the parameter type '(DataSnapshot) → FutureOr&lt;dynamic&gt;'.
  </code></pre>
  
  <p>And here is my code:</p>
  
  <pre><code>getAccountsList() {
    return firebaseDbService.getAccounts().once().then((DataSnapshot snapshot) {
      var list = [];
      snapshot.forEach((DataSnapshot account) =&gt; list.add({
        'id': snapshot.key,
        'name': snapshot.child('name').val(),
      }));
      return list;
    });
  }
  </code></pre>