title: What is the alternative to swift’s DispatchGroup in flutter/dart?
body: <p>I would like to know how I can write this code in flutter/dart? I don't know any Class in the flutter that can notify certain code to execute after another code completes. </p>
  
  <pre><code>var posts = [Post]()
  
          let dispatchGroup = DispatchGroup()
  
          snapshot.forEach({ (postSnapshot) in
              guard let postDict = postSnapshot.value as? [String : Any],
                  let posterUID = postDict["poster_uid"] as? String
                  else { return }
  
              let postKey = postSnapshot.key
  
              dispatchGroup.enter()
  
              showUserPost(forKey: postKey, posterUID: posterUID) { (post) in
                  if let post = post {
                      posts.append(post)
                  }
  
                  dispatchGroup.leave()
              }
          })
  
          dispatchGroup.notify(queue: .main, execute: {
              completion(nil, posts.reversed())
          })
  </code></pre>