Baseflow / flutter_cached_network_image

Download, cache and show images in a flutter app
https://baseflow.com
2.41k stars 641 forks source link

How can I add image to cache manually. #763

Open un-hongly opened 1 year ago

un-hongly commented 1 year ago

Hi here, I want to add some images to cache manager manually for CachedNetworkImage. My code below doesn't work so what can I do to achieve that?

  // storing cache
  String imageUrl = 'some url';
  String cacheKey = 'some_key';
  DefaultCacheManager cacheManager = DefaultCacheManager();
  await cacheManager.downloadFile(imageUrl, key:  cacheKey);

  // render image
  CachedNetworkImage(
    cacheManager: cacheManager,
    cacheKey: cacheKey,
    imageUrl:  'imageUrl',
  ),
dev-zl commented 1 year ago

Hi here, I want to add some images to cache manager manually for CachedNetworkImage. My code below doesn't work so what can I do to achieve that?

  // storing cache
  String imageUrl = 'some url';
  String cacheKey = 'some_key';
  DefaultCacheManager cacheManager = DefaultCacheManager();
  await cacheManager.downloadFile(imageUrl, key:  cacheKey);

  // render image
  CachedNetworkImage(
    cacheManager: cacheManager,
    cacheKey: cacheKey,
    imageUrl:  'imageUrl',
  ),

look at this https://github.com/Baseflow/flutter_cached_network_image/issues/621