From 278c6a37160adc854f0c8aa5504e48f9add302b1 Mon Sep 17 00:00:00 2001 From: Apurva Kanthraviya Date: Tue, 2 Jul 2024 13:54:14 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20handle=20snackBar=20queue?= =?UTF-8?q?=20while=20reacting=20on=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix if already snackBar is there then it open new snackBar on previous one. --- lib/src/widgets/chat_list_widget.dart | 88 +++++++++++++-------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/lib/src/widgets/chat_list_widget.dart b/lib/src/widgets/chat_list_widget.dart index 87278c3c..4987c38a 100644 --- a/lib/src/widgets/chat_list_widget.dart +++ b/lib/src/widgets/chat_list_widget.dart @@ -199,50 +199,50 @@ class _ChatListWidgetState extends State }) { final replyPopup = chatListConfig.replyPopupConfig; ScaffoldMessenger.of(context) - .showSnackBar( - SnackBar( - duration: const Duration(hours: 1), - backgroundColor: replyPopup?.backgroundColor ?? Colors.white, - content: replyPopup?.replyPopupBuilder != null - ? replyPopup!.replyPopupBuilder!(message, sentByCurrentUser) - : ReplyPopupWidget( - buttonTextStyle: replyPopup?.buttonTextStyle, - topBorderColor: replyPopup?.topBorderColor, - onMoreTap: () { - _onChatListTap(); - replyPopup?.onMoreTap?.call( - message, - sentByCurrentUser, - ); - }, - onReportTap: () { - _onChatListTap(); - replyPopup?.onReportTap?.call( - message, - ); - }, - onUnsendTap: () { - _onChatListTap(); - replyPopup?.onUnsendTap?.call( - message, - ); - }, - onReplyTap: () { - widget.assignReplyMessage(message); - if (featureActiveConfig?.enableReactionPopup ?? false) { - showPopUp.value = false; - } - ScaffoldMessenger.of(context).hideCurrentSnackBar(); - if (replyPopup?.onReplyTap != null) { - replyPopup?.onReplyTap!(message); - } - }, - sentByCurrentUser: sentByCurrentUser, - ), - padding: EdgeInsets.zero, - ), - ) - .closed; + ..clearSnackBars() + ..showSnackBar( + SnackBar( + duration: const Duration(hours: 1), + backgroundColor: replyPopup?.backgroundColor ?? Colors.white, + content: replyPopup?.replyPopupBuilder != null + ? replyPopup!.replyPopupBuilder!(message, sentByCurrentUser) + : ReplyPopupWidget( + buttonTextStyle: replyPopup?.buttonTextStyle, + topBorderColor: replyPopup?.topBorderColor, + onMoreTap: () { + _onChatListTap(); + replyPopup?.onMoreTap?.call( + message, + sentByCurrentUser, + ); + }, + onReportTap: () { + _onChatListTap(); + replyPopup?.onReportTap?.call( + message, + ); + }, + onUnsendTap: () { + _onChatListTap(); + replyPopup?.onUnsendTap?.call( + message, + ); + }, + onReplyTap: () { + widget.assignReplyMessage(message); + if (featureActiveConfig?.enableReactionPopup ?? false) { + showPopUp.value = false; + } + ScaffoldMessenger.of(context).hideCurrentSnackBar(); + if (replyPopup?.onReplyTap != null) { + replyPopup?.onReplyTap!(message); + } + }, + sentByCurrentUser: sentByCurrentUser, + ), + padding: EdgeInsets.zero, + ), + ).closed; } void _onChatListTap() {