fillUserInfo static method

Future<List<ChatMessage>> fillUserInfo(
  1. List<NIMMessage> list
)

为每条消息添加用户信息

Implementation

static Future<List<ChatMessage>> fillUserInfo(List<NIMMessage> list) async {
  List<ChatMessage> result = [];
  for (var element in list) {
    ChatMessage message = ChatMessage(element);
    var contact = await getIt<ContactProvider>()
        .getContact(element.fromAccount!, needFriend: false);
    message.fromUser = contact?.user;
    result.add(message);
  }
  return result;
}