createFriendGroup static method

Future<V2TimValueCallback<List<V2TimFriendOperationResult>>> createFriendGroup({
  1. required String groupName,
  2. List<String>? userIDList,
})

Implementation

static Future<V2TimValueCallback<List<V2TimFriendOperationResult>>> createFriendGroup({
  required String groupName,
  List<String>? userIDList,
}) async {
  String param = json.encode({
    "friendship_create_friend_group_param_name_array": List<String>.from([groupName]),
    "friendship_create_friend_group_param_identifier_array": userIDList,
  });
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  Pointer<Uint8> json_create_friend_group_param = Tools.string2PointerInt8(param);
  int res = desktopSDK.D_TIMFriendshipCreateFriendGroup(json_create_friend_group_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<List<V2TimFriendOperationResult>>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    List<Map<String, dynamic>> dataList = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
    List<Map<String, dynamic>> list = List<Map<String, dynamic>>.empty(growable: true);
    for (var element in dataList) {
      Map<String, dynamic> json = Map.from(element);
      V2TimFriendOperationResult result = V2TimFriendOperationResult.fromJson({
        "userID": json["friend_result_identifier"],
        "resultCode": json["friend_result_code"],
        "resultInfo": json["friend_result_desc"],
        // "resultType":
      });
      list.add(result.toJson());
    }
    return V2TimValueCallback<List<V2TimFriendOperationResult>>.fromJson({
      "code": data["code"],
      "desc": data["desc"],
      "data": list,
    });
  }
}