sendTextMessage method

Future<void> sendTextMessage(
  1. String text, {
  2. Message? replay,
  3. dynamic mention,
})

Implementation

Future<void> sendTextMessage(
  String text, {
  Message? replay,
  dynamic mention,
}) async {
  Message message = Message.createTxtSendMessage(
    targetId: profile.id,
    chatType: chatType,
    content: text,
  );

  if (mention != null) {
    Map<String, dynamic> mentionExt = {};
    if (mention is bool && mention == true) {
      mentionExt[mentionKey] = mentionAllValue;
    } else if (mention is List<String>) {
      List<String> mentionList = [];
      for (var userId in mention) {
        {
          mentionList.add(userId);
        }
      }
      if (mentionList.isNotEmpty) {
        mentionExt[mentionKey] = mentionList;
      }
    }
    if (mentionExt.isNotEmpty) {
      message.attributes = mentionExt;
    }
  }

  if (replay != null) {
    message.addQuote(replay);
  }

  await sendMessage(message);
}