getOrDownload method

FutureOr<S> getOrDownload()

Returns entity from cache or tries to download from API if not found. If downloading is successful it caches results

Implementation

FutureOr<S> getOrDownload() async {
  final cacheResult = getFromCache();

  if (cacheResult != null) {
    return cacheResult;
  }

  return download();
}