getDialogs method

Future<List<QBDialog?>> getDialogs({
  1. QBSort? sort,
  2. QBFilter? filter,
  3. int? limit,
  4. int? skip,
})

Implementation

Future<List<QBDialog?>> getDialogs({QBSort? sort, QBFilter? filter, int? limit, int? skip}) async {
  Map<String, Object> data = Map();

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

  Map<Object?, Object?> map = await _chatModule.invokeMethod(GET_DIALOGS_METHOD, data);

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

  List<QBDialog?> dialogList = [];

  for (final dialogMap in list) {
    QBDialog? qbDialog = QBDialogMapper.mapToQBDialog(dialogMap as Map<Object?, Object?>);
    dialogList.add(qbDialog);
  }

  return dialogList;
}