loadListData method

Future<Result<List<T>>> loadListData()

Implementation

Future<Result<List<T>>> loadListData() async {
  status = ListStatus.LOADING;
  Result<List<T>> res = await loadData(pagingHelper);
  return res.maybeMap(
    success: (value) {
      status = ListStatus.LOADED;
      listData == null ? listData = value.data : listData?.addAll(value.data);
      return Success(data: listData!);
    },
    failure: (value) {
      status = ListStatus.ERROR;
      error = value.reason;
      return value;
    },
    orElse: () {
      status = ListStatus.ERROR;
      return const Failure(reason: "Unknown Error");
    },
  );
}