fluttercommunity / flutter_blurhash

Compact representation of a placeholder for an image. Encode a blurry image under 30 caracters for instant display like used by Medium. Maintainer: @Solido
https://pub.dev/packages/flutter_blurhash
MIT License
523 stars 66 forks source link

CacheManager #61

Open simplenotezy opened 1 year ago

simplenotezy commented 1 year ago

Is there a way to control CacheManager?

Today we have added Blurhash like below, but I noticed we could also add in the actual url to blurhash as a parameter, and thus perhaps we could eliminate a lot of our own code (and hopefully piggyback-ride onto an smoother transition from blur to image).

CachedNetworkImage(
  imageUrl: url,
  fadeInCurve: Curves.linear,
  fadeOutCurve: Curves.linear,
  fit: BoxFit.cover,
  width: width,
  height: height,
  fadeInDuration: Duration(milliseconds: 250),
  fadeOutDuration: Duration(milliseconds: 250),
  cacheManager: CacheManager(
    Config(
      url,
      maxNrOfCacheObjects: 500,
      stalePeriod: stalePeriod ?? const Duration(days: 30),
    ),
  ),
  placeholder: Stack(
    fit: StackFit.expand,
    children: [
      BlurHash(
        hash: image.blurhash,
        imageFit: BoxFit.cover,
      ),
      Center(
        child: LoadingSpinner(
          radius: spinnerRadius ?? 15,
          strokeWidth: spinnerStrokeWidth ?? 1,
        ),
      ),
    ],
  ),
  errorWidget: (context, _, __) => ProfilePlaceholder(width: width, height: height),
)

However, it would be ideal for us to control errorWidget as well as the cacheManager.