Skip to content

Instantly share code, notes, and snippets.

@iskakaushik
Created April 9, 2019 22:42
Show Gist options
  • Save iskakaushik/5868869a6312e52df53f89ba9de083c4 to your computer and use it in GitHub Desktop.
Save iskakaushik/5868869a6312e52df53f89ba9de083c4 to your computer and use it in GitHub Desktop.
class SizeAwareImageCacheKey {
const SizeAwareImageCacheKey(this._providerCacheKey, this._imageSize);
final dynamic _providerCacheKey;
final Size _imageSize;
}
class SizeAwareImageProvicer
extends ImageProvider<SizeAwareImageCacheKey> {
const SizeAwareImageProvicer(this._imageProvider, this.imageSize);
final ImageProvider _imageProvider;
final Size imageSize;
@override
ImageStreamCompleter load(SizeAwareImageCacheKey key) {
return _imageProvider.load(key._providerCacheKey, size: key._imageSize);
}
@override
Future<SizeAwareImageCacheKey> obtainKey(
ImageConfiguration configuration) async {
final dynamic providerCacheKey = _imageProvider.obtainKey(configuration);
return SizeAwareImageCacheKey(providerCacheKey, imageSize);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment