sendMessage method

void sendMessage(
  1. String msg,
  2. bool isBroadCast,
  3. List<String> recipientIDs,
  4. String group,
)

Implementation

void sendMessage(
    String msg, bool isBroadCast, List<String> recipientIDs, String group) {
  EnxRtc.sendMessage(msg, isBroadCast, recipientIDs);
  // print("msf$msg id${recipientIDs.first}");

  chatModel = ChatModel(
      isBroadCast,
      recipientIDs.isNotEmpty ? recipientIDs.first : '',
      group,
      isBroadCast ? 'group' : 'private',
      msg,
      getCurrentTime(),
      false,
      FileShareModel(0, "", false),
      "", {});

  if (isBroadCast) {
    chatList.add(chatModel!);
  } else {
    print('rtg${privateChatListData.length}');

    privateChatList.add(chatModel!);
    if (getChatType == 'private') {
      for (var chatData in privateChatListData) {
        if (chatData.clientId == chatModel!.senderId) {
          chatData.chatList.add(chatModel!);
          print('rtg2${chatData.chatList.length}');
        }
      }
    }
  }

  scrollToBottom(scrollController);
  privateChatListData.refresh();

  update();
}