Skip to content

Commit f58e1b4

Browse files
committed
Fix listMessage is appending snapshots infinitely
1 parent f458901 commit f58e1b4

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/pages/chat_page.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ChatPageState extends State<ChatPage> {
3939
String peerNickname;
4040
late String currentUserId;
4141

42-
List<QueryDocumentSnapshot> listMessage = new List.from([]);
42+
List<QueryDocumentSnapshot> listMessage = [];
4343
int _limit = 20;
4444
int _limitIncrement = 20;
4545
String groupChatId = "";
@@ -662,7 +662,7 @@ class ChatPageState extends State<ChatPage> {
662662
stream: chatProvider.getChatStream(groupChatId, _limit),
663663
builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
664664
if (snapshot.hasData) {
665-
listMessage.addAll(snapshot.data!.docs);
665+
listMessage = snapshot.data!.docs;
666666
return ListView.builder(
667667
padding: EdgeInsets.all(10),
668668
itemBuilder: (context, index) => buildItem(index, snapshot.data?.docs[index]),

0 commit comments

Comments
 (0)