getGroupMemberList static method

Future<V2TimValueCallback<V2TimGroupMemberInfoResult>> getGroupMemberList({
  1. required String groupID,
  2. required int filter,
  3. required String nextSeq,
  4. int count = 15,
  5. int offset = 0,
})

Implementation

static Future<V2TimValueCallback<V2TimGroupMemberInfoResult>> getGroupMemberList({
  required String groupID,
  required int filter,
  required String nextSeq,
  int count = 15,
  int offset = 0,
}) async {
  String param = json.encode({
    "group_get_members_info_list_param_group_id": groupID,
    "group_get_members_info_list_param_option": Map.from({
      "group_member_get_info_option_role_flag": filter, // 0 1 2 3
      //     kTIMGroupMemberRoleFlag_All    = 0x00,       // 获取全部角色类型
      // kTIMGroupMemberRoleFlag_Owner  = 0x01,       // 获取所有者(群主)
      // kTIMGroupMemberRoleFlag_Admin  = 0x01 << 1,  // 获取管理员,不包括群主
      // kTIMGroupMemberRoleFlag_Member = 0x01 << 2,  // 获取普通群成员,不包括群主和管理员
    }),
    "group_get_members_info_list_param_next_seq": int.parse(nextSeq.isEmpty ? "0" : nextSeq),
  });
  print(param);
  String userData = Tools.generateUserData();
  Pointer<Uint8> user_data = Tools.string2PointerInt8(userData);
  Pointer<Uint8> json_group_getmeminfos_param = Tools.string2PointerInt8(param);
  int res = desktopSDK.D_TIMGroupGetMemberInfoList(json_group_getmeminfos_param, user_data);
  if (res != TIMResult.TIM_SUCC) {
    return V2TimValueCallback<V2TimGroupMemberInfoResult>.fromJson({
      "code": res,
      "desc": "",
    });
  } else {
    Map<String, dynamic> data = await getAsyncData(apiKey: userData);
    Map<String, dynamic> nativeData = Map<String, dynamic>.from(json.decode(data["json_param"].isEmpty ? json.encode({}) : data["json_param"]));

    List<Map<String, dynamic>> dartList = List<Map<String, dynamic>>.from(nativeData["group_get_member_info_list_result_info_array"] ?? []);
    List<Map<String, dynamic>> memList = List.empty(growable: true);
    for (var element in dartList) {
      memList.add(Tools.memberInfo2DartFullInfo(element).toJson());
    }
    Map<String, dynamic> dartRes = Map<String, dynamic>.from({
      "nextSeq": nativeData["group_get_member_info_list_result_next_seq"].toString(),
      "memberInfoList": memList,
    });

    return V2TimValueCallback<V2TimGroupMemberInfoResult>.fromJson({"code": data["code"], "desc": data["desc"], "data": dartRes});
  }
}