readList method

  1. @override
FutureOr<ReadListResult> readList(
  1. Access access
)
override

Implementation

@override
FutureOr<ReadListResult> readList(Access access) {
  if (access.query?.selector != null) {
    Logger.of(context).warn(context, "query_not_supported",
        title: "Query selector "
            "not supported with SimpleCacheDataAccess , so its skipped");
  }

  if (access.query?.sort != null) {
    Logger.of(context).warn(context, "sort_not_supported",
        title: "Query sort "
            "not supported with SimpleCacheDataAccess , so its skipped");
  }
  if (access.query?.fields != null) {
    Logger.of(context).warn(context, "sort_not_supported",
        title: "Query fields "
            "not supported with SimpleCacheDataAccess , so its skipped");
  }
  var l = access.query?.limit ?? 200;
  var s = access.query?.offset ?? 0;

  var len = data[access.collection]?.length ?? 0;

  var nLen = len - s;

  if (nLen <= 0) {
    return ReadListResult(data: []);
  }

  if (l >= nLen) {
    l = nLen;
  }

  return ReadListResult(
      data: _copy(
          data[access.collection]?.values.toList().sublist(s).sublist(0, l)));
}