setFriendInfo static method

Future<V2TimCallback> setFriendInfo({
  1. required String userID,
  2. String? friendRemark,
  3. Map<String, String>? friendCustomInfo,
})

Implementation

static Future<V2TimCallback> setFriendInfo({
  required String userID,
  String? friendRemark,
  Map<String, String>? friendCustomInfo,
}) async {
  List<Map<String, dynamic>> customArray = List.empty(growable: true);
  friendCustomInfo?.forEach((key, value) {
    customArray.add({
      "friend_profile_custom_string_info_key": key,
      "friend_profile_custom_string_info_value": value,
    });
  });
  String param = json.encode({
    "friendship_modify_friend_profile_param_identifier": userID,
    "friendship_modify_friend_profile_param_item": Map<String, dynamic>.from({
      "friend_profile_item_remark": friendRemark,
      "friend_profile_item_custom_string_array": customArray,
    }),
  });
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  Pointer<Uint8> json_modify_friend_info_param = Tools.string2PointerInt8(param);
  int res = desktopSDK.D_TIMFriendshipModifyFriendProfile(json_modify_friend_info_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimCallback.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    return V2TimCallback.fromJson({
      "code": data["code"],
      "desc": data["desc"],
    });
  }
}