title: Flutter : how to get newly added record from firebase real time database?
body: <p>I'm using below code to retrieve all the data from my firebase chat room</p>
  
  <pre><code>void readDataFromFireBase() {
  
      var databaseReference =
          FirebaseDatabase.instance.reference().child("messages");
  
      databaseReference
          .child(chatroom.chatId)
          .once()
          .then((DataSnapshot snapshot) {
        Map&lt;dynamic, dynamic&gt; values = snapshot.value;
  
        values.forEach((key, value) {
          setState(() {
            chatMessageList.add(ChatMessage(
                value["message"], value["fromUser"], value["timestamp"]));
            chatMessageList.sort((a, b) {
              var formatter = new DateFormat('MM/dd/yyyy, kk:mm');
              var dateOne = formatter.parse(a.timestamp);
              var selectedDate = formatter.parse(b.timestamp);
              return dateOne.compareTo(selectedDate);
            });
  
  
        });
      });
    }
  </code></pre>
  
  <p>now how can i get notify my chat room when the new message has arrived </p>
  
  <p>currently i'm using below code to listen child added event </p>
  
  <pre><code>listenDataFromFireBase() {
      var db = FirebaseDatabase.instance.reference().child("messages");
      db.child(chatroom.chatId).onChildAdded.listen((data) {
        print("GET_NEW_DATA");
        print(data.snapshot.value["message"] ?? '');
        print(data.snapshot.value["fromUser"] ?? false);
        print(data.snapshot.value["timestamp"] ?? '');
      });
    }
  </code></pre>
  
  <p>but there is one issue i'm facing this <code>listenDataFromFireBase()</code> load all the the data from particular room</p>
  
  <p>My requirement is whenever new message added in chatroom i want to animate my message layout</p>
  
  <p>How can i get notify my screen whenever new message will add in my chat room.</p>
  
  <p>If need more information please do let me know. Thanks in advance. Your efforts will be appreciated. </p>