cacheUrl static method

Future<Cache> cacheUrl(
  1. String url
)

Implementation

static Future<Cache> cacheUrl(String url) async {
  if (!isCacheLoaded) {
    return Cache(key: url, byteList: await http.readBytes(Uri.parse(url)));
  }
  final qres = cacheBox.query(Cache_.key.equals(url)).build().findFirst();
  if (qres != null) {
    return qres;
  }
  final resp = await http.readBytes(Uri.parse(url));
  final c = Cache(key: url, byteList: resp)..save();
  return c;
}