searchGroups static method

Future<V2TimValueCallback<List<V2TimGroupInfo>>> searchGroups({
  1. required V2TimGroupSearchParam searchParam,
})

Implementation

static Future<V2TimValueCallback<List<V2TimGroupInfo>>> searchGroups({
  required V2TimGroupSearchParam searchParam,
}) async {
  String userData = Tools.generateUserData();

  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  List<int> fild = List.empty(growable: true);
  if (searchParam.isSearchGroupID) {
    fild.add(0x01);
  }
  if (searchParam.isSearchGroupName) {
    fild.add(0x01 << 1);
  }
  String param = json.encode({
    "group_search_params_keyword_list": searchParam.keywordList,
    "group_search_params_field_list": fild,
  });
  Pointer<Uint8> json_group_search_groups_param = Tools.string2PointerInt8(param);
  int res = desktopSDK.D_TIMGroupSearchGroups(json_group_search_groups_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<List<V2TimGroupInfo>>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    List<Map<String, dynamic>> listData = List<Map<String, dynamic>>.from(json.decode(data["json_param"].isEmpty ? json.encode([]) : data["json_param"]));
    List<Map<String, dynamic>> dartListData = List<Map<String, dynamic>>.empty(growable: true);
    for (var element in listData) {
      Map<String, dynamic> nativeJson = Map<String, dynamic>.from(element);
      Map<String, dynamic> dartJson = Tools.groupDetail2DartGroupInfo(nativeJson).toJson();
      dartListData.add(dartJson);
    }
    return V2TimValueCallback<List<V2TimGroupInfo>>.fromJson({
      "code": data["code"],
      "desc": data["desc"],
      "data": dartListData,
    });
  }
}