readList<S> method

List<S> readList<S>(
  1. CacheModel<Serializable> model
)

Implementation

List<S> readList<S>(final CacheModel model) {
  _log(model.key, "Reading Cache data for list ${model.key}");
  final cacheData = storage.read(model.key);
  if (cacheData == null) {
    return [];
  }
  if (cacheData.runtimeType != List) {
    throw AppException(
        message:
            "Invalid Runtime Type. Expected type: List. Actual: ${cacheData.runtimeType}");
  }
  return (cacheData as List)
      .map<S>((item) => model.value.fromJson(item))
      .toList();
}