fetchReactionList method Null safety

Future<Map<String, List<EMMessageReaction>>> fetchReactionList(
  1. {required List<String> messageIds,
  2. required ChatType chatType,
  3. String? groupId}
)

Gets the list of Reactions.

Param messageIds The message IDs.

Param chatType The chat type. Only one-to-one chat ({@link EMMessage.ChatType#Chat} and group chat ({@link EMMessage.ChatType#GroupChat}) are allowed.

Param groupId which is invalid only when the chat type is group chat.

Return The Reaction list under the specified message ID(The UserList of EMMessageReaction is the summary data, which only contains the information of the first three users).

Throws A description of the exception. See {@link EMError}.

Implementation

Future<Map<String, List<EMMessageReaction>>> fetchReactionList({
  required List<String> messageIds,
  required ChatType chatType,
  String? groupId,
}) async {
  Map req = {
    "msgIds": messageIds,
    "chatType": chatTypeToInt(chatType),
  };
  req.setValueWithOutNull("groupId", groupId);
  Map result = await EMMethodChannel.ChatManager.invokeMethod(
      ChatMethodKeys.fetchReactionList, req);

  try {
    EMError.hasErrorFromResult(result);
    Map<String, List<EMMessageReaction>> ret = {};
    for (var info in result.entries) {
      List<EMMessageReaction> reactions = [];
      for (var item in info.value) {
        reactions.add(EMMessageReaction.fromJson(item));
      }
      ret[info.key] = reactions;
    }
    return ret;
  } on EMError catch (e) {
    throw e;
  }
}