getList method

  1. @override
Future<Stream<ResponseDataDataSource>> getList(
  1. int limit,
  2. int offset,
  3. SelectModel? selectModel, {
  4. Map? data,
  5. bool refresh = false,
  6. ItemSort? itemSort,
  7. GroupFilterExp? filter,
})

Implementation

@override
Future<Stream<ResponseDataDataSource>> getList(
  int limit,
  int offset,
  SelectModel? selectModel, {
  Map? data,
  bool refresh = false,
  ItemSort? itemSort,
  GroupFilterExp? filter,
}) async {
  if (listAll == null ||
      listAll!.isEmpty ||
      refresh == true ||
      // Caso o itemSort tenha sido anulado, atualiza a lista para restaurar a formatação padrão
      (itemSort == null && _currentSort != null)) {
    listAll?.clear();
    listAll = await fetchData(limit, offset, selectModel, data: data);
  }

  if (itemSort != _currentSort) {
    listAll = applySort(itemSort, selectModel!.id, listAll);
  }

  List<Map<String, dynamic>> tempList = applyFilters(listAll!, filter);
  List<Map<String, dynamic>> subList = getSubList(offset, limit, tempList);
  return Stream.value(ResponseDataDataSource(
      total: tempList.length,
      data: generateList(subList, offset, selectModel!),
      start: offset,
      end: offset + limit));
}