Skip to main content

sendMessageToDirectChat method

Future<void> sendMessageToDirectChat (String chatId, String messageContent)

This function is used to send the message in the direct chats.

parameters required:

  • chatId - id of the direct chat where message need to be send.
  • messageContent - the text that need to be send.

Implementation

Future<void> sendMessageToDirectChat(
String chatId,
String messageContent,
) async {
// trigger graphQL mutation to push the message in the Database.
final result = await _dbFunctions.gqlAuthMutation(
ChatQueries().sendMessageToDirectChat(),
variables: {"chatId": chatId, "messageContent": messageContent},
);

final message = ChatMessage.fromJson(
result.data['sendMessageToDirectChat'] as Map<String, dynamic>,
);

_chatMessageController.add(message);

debugPrint(result.data.toString());
}