getUsers method

Future<List<QBUser?>> getUsers({
  1. QBSort? sort,
  2. QBFilter? filter,
  3. int page = 1,
  4. int perPage = 100,
})

Implementation

Future<List<QBUser?>> getUsers({QBSort? sort, QBFilter? filter, int page = 1, int perPage = 100}) async {
  Map<String, Object> data = Map();

  data["page"] = page;
  data["perPage"] = perPage;

  if (sort != null) {
    data["sort"] = QBSortMapper.sortToMap(sort)!;
  }
  if (filter != null) {
    data["filter"] = QBFilterMapper.filterToMap(filter)!;
  }

  Map<Object?, Object?> map = await _usersModule.invokeMethod(GET_METHOD, data);

  List<Object?> list = map["users"] as List<Object?>;

  List<QBUser?> userList = [];

  for (final item in list) {
    QBUser? qbUser = QBUserMapper.mapToQBUser(item as Map<dynamic, dynamic>);
    userList.add(qbUser);
  }

  return userList;
}