Receive a Chat Message
To receive chat messages, implement the onChatUpdates(...) method from callback DyteChatEventsListener. You can subscribe to these events by calling the following:
class ChatEventsListener with DyteChatEventsListener {
  ...
  
  void onChatUpdates(List<DyteChatMessage> messages) {
    messages.map((msg) {
      switch (msg.type) {
        case DyteMessageType.text:
          print((msg as DyteTextMessage).displayName);
          print((msg).message);
          // Show message/return state to show text message UI.
          break;
        case DyteMessageType.image:
          print((msg as DyteImageMessage).displayName);
          print((msg).link);
          // Show message/return state to show image message UI.
          break;
        case DyteMessageType.file:
          print((msg as DyteFileMessage).name);
          print((msg).link);
          print((msg).size);
          // Show message/return state to show file message UI.
          break;
      }
    });
  }
  void onNewChatMessage(DyteChatMessage message) {
      // your code to handle new chat message
  }
  ...
}
dyteClient.addChatEventsListener(ChatEventsListener());
In this context, messages refers to a list of all the chat messages in the meeting. The type of message used is DyteChatMessage, which was introduced earlier in the introduction to Chat topic.
Whenever a chat message is received, the dyteClient.chat.messages list is automatically updated.