downloadAndCacheImage method

Future<Uint8List?> downloadAndCacheImage(
  1. String url, {
  2. Map<String, String>? headers,
  3. String? cacheKey,
})

Implementation

Future<Uint8List?> downloadAndCacheImage(
    String url, {
      Map<String, String>? headers,
      String? cacheKey,
    }) async {
  try {
    final id = _id(url, cacheKey);
    final info = await _cacheManager.downloadFile(url, key: id, authHeaders: headers);
    _touch(id);
    _setCache(id, info);
    return _bytes(info);
  } catch (e) {
    return null;
  }
}