sendChatMessage method
- ChatId chatId, {
- ChatMessageText? text,
- List<Attachment> ? attachments,
- List<ChatItem> repliesTo = const [],
override
    Posts a new ChatMessage to the specified Chat by the authenticated MyUser.
For the posted ChatMessage to be meaningful, at least one of text or
attachments arguments must be specified and non-empty.
Specify repliesTo argument if the posted ChatMessage is going to be a
reply to some other ChatItem.
Implementation
@override
Future<void> sendChatMessage(
  ChatId chatId, {
  ChatMessageText? text,
  List<Attachment>? attachments,
  List<ChatItem> repliesTo = const [],
}) async {
  Log.debug(
    'sendChatMessage($chatId, $text, $attachments, $repliesTo)',
    '$runtimeType',
  );
  RxChatImpl? rxChat = chats[chatId] ?? await get(chatId);
  ChatItem? local;
  if (chatId.isLocal) {
    local = await rxChat?.postChatMessage(
      existingDateTime: PreciseDateTime.now().add(10.seconds),
      text: text,
      attachments: attachments,
      repliesTo: repliesTo,
    );
    try {
      rxChat = await ensureRemoteDialog(chatId);
    } catch (_) {
      local?.status.value = SendingStatus.error;
    }
  }
  await rxChat?.postChatMessage(
    existingId: local?.id,
    existingDateTime: local?.at,
    text: text,
    attachments: attachments,
    repliesTo: repliesTo,
  );
}