buildLastMessageItem method

FutureBuilder<ChatMessageModel> buildLastMessageItem()

Implementation

FutureBuilder<ChatMessageModel> buildLastMessageItem() {
  return FutureBuilder(
      future: getMessageOfId(item.lastMessageId.checkNull()),
      builder: (context, data) {
        if (data.hasData && data.data != null && !data.hasError) {
          var chat = data.data!;
          return Row(
            children: [
              (item.isGroup.checkNull() &&
                  !chat.isMessageSentByMe.checkNull() &&
                  (chat.messageType != Constants.mNotification ||
                      chat.messageTextContent == " added you") || (item.isGroup.checkNull() && (forMessageTypeString(chat.messageType,
                  content: chat.messageTextContent.checkNull()).checkNull().isNotEmpty)))
                  ? Flexible(
                    child: Text(
                    chat.senderUserName.checkNull().isNotEmpty ? "${chat.senderUserName.checkNull()}:" : "${chat.senderNickName.checkNull()}:",
                        style: TextStyle(color: MirrorflyUikit.getTheme?.textSecondaryColor),
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                      ),
                  )
                  : const SizedBox.shrink(),
              chat.isMessageRecalled.value
                  ? const SizedBox.shrink() : forMessageTypeIcon(
                  chat.messageType, chat.mediaChatMessage),
              SizedBox(
                width: chat.isMessageRecalled.value
                    ? 0.0
                    : forMessageTypeString(chat.messageType,
                    content:
                    chat.messageTextContent.checkNull()) !=
                    null
                    ? 3.0
                    : 0.0,
              ),
              Expanded(
                child: spanTxt.isEmpty
                    ? Text(
                  chat.isMessageRecalled.value
                            ? setRecalledMessageText(
                      chat.isMessageSentByMe)
                            : forMessageTypeString(chat.messageType,
                                    content: chat.mediaChatMessage
                                        ?.mediaCaptionText
                                        .checkNull()) ??
                      chat.messageTextContent.checkNull(),
                        style: TextStyle(color: MirrorflyUikit.getTheme?.textSecondaryColor),
                        maxLines: 1,
                        overflow: TextOverflow.ellipsis,
                      )
                    : spannableText(
                    chat.isMessageRecalled.value
                            ? setRecalledMessageText(
                        chat.isMessageSentByMe)
                            : forMessageTypeString(
                        chat.messageType.checkNull(),
                                    content: chat.mediaChatMessage
                                        ?.mediaCaptionText
                                        .checkNull()) ??
                        chat.messageTextContent.checkNull(),
                        spanTxt,
                        TextStyle(color: MirrorflyUikit.getTheme?.textSecondaryColor)),
              ),
            ],
          );
        }
        return const SizedBox();
      });
}