supplyUserInfo method

Future<void> supplyUserInfo(
  1. String userID,
  2. V2TimConversation conversation
)

Implementation

Future<void> supplyUserInfo(String userID, V2TimConversation conversation) async {
  V2TimValueCallback<List<V2TimFriendInfoResult>> result = await TIMFriendshipManager.instance.getFriendsInfo(userIDList: [userID]);
  if (result.code == 0 && result.data!.isNotEmpty) {
    V2TimFriendInfoResult friendInfoResult = result.data![0];
    if (friendInfoResult.resultCode == 0) {
      String? showName = friendInfoResult.friendInfo?.friendRemark;
      if (showName == null || showName.isEmpty) {
        showName = friendInfoResult.friendInfo?.userProfile?.nickName;
      }

      if (showName == null || showName.isEmpty) {
        showName = friendInfoResult.friendInfo?.userProfile?.userID;
      }

      conversation.showName = friendInfoResult.friendInfo?.userProfile?.nickName;
      conversation.faceUrl = friendInfoResult.friendInfo?.userProfile?.faceUrl;
    }
  }
}