chatListView method
Implementation
Widget chatListView(List<ChatMessageModel> chatList) {
return ScrollablePositionedList.builder(
itemCount: chatList.length,
//initialScrollIndex: chatList.length,
itemScrollController: controller.searchScrollController,
itemPositionsListener: controller.itemPositionsListener,
reverse: true,
itemBuilder: (context, index) {
return Column(
children: [
groupedDateMessage(index, chatList) != null
? NotificationMessageView(
chatMessage: groupedDateMessage(index, chatList))
: const SizedBox.shrink(),
(chatList[index].messageType.toUpperCase() !=
Constants.mNotification)
? Container(
color: chatList[index].isSelected.value
? MirrorflyUikit.getTheme?.primaryColor.withAlpha(60)
: Colors.transparent,
margin: const EdgeInsets.only(
left: 14, right: 14, top: 5, bottom: 10),
child: Align(
alignment: (chatList[index].isMessageSentByMe
? Alignment.bottomRight
: Alignment.bottomLeft),
child: Row(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children: [
Visibility(
visible: chatList[index].isMessageSentByMe &&
controller
.forwardMessageVisibility(chatList[index]),
child: IconButton(
onPressed: () {
controller.forwardSingleMessage(
chatList[index].messageId);
},
icon: SvgPicture.asset(
package: package,
forwardMedia,
)),
),
ChatContainer(
chatMessage: chatList[index],
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SenderHeader(
isGroupProfile:
controller.profile.isGroupProfile,
chatList: chatList,
index: index),
chatList[index].isThisAReplyMessage
? chatList[index].replyParentChatMessage ==
null
? messageNotAvailableWidget(
chatList[index])
: ReplyMessageHeader(
chatMessage: chatList[index])
: const SizedBox.shrink(),
MessageContent(
chatList: chatList,
index: index,
search: controller.searchedText.text.trim(),
onPlayAudio: () {
controller.playAudio(chatList[index]);
},
onSeekbarChange: (value) {},
showChatDeliveryIndicator:
showChatDeliveryIndicator,
),
],
),
),
Visibility(
visible: !chatList[index].isMessageSentByMe &&
controller
.forwardMessageVisibility(chatList[index]),
child: IconButton(
onPressed: () {
controller.forwardSingleMessage(
chatList[index].messageId);
},
icon: SvgPicture.asset(
package: package,
forwardMedia,
)),
),
],
),
),
)
: NotificationMessageView(
chatMessage: chatList[index].messageTextContent),
],
);
},
);
}