addGifToCache method
Add gif to cache
image - gif provider to cache
clearTimeout - afterTimeout remove gif from cache to avoid ram usage
if clearTimeout is null - not call clear func.
Implementation
Future<void> addGifToCache(ImageProvider<Object> image,
{Duration? clearTimeout}) async {
final path = _getImageKey(image);
if (_caches.containsKey(path)) {
return;
}
final frames = await _fetchFrames(image);
_caches.putIfAbsent(_getImageKey(image), () => frames);
if (clearTimeout != null) {
Future.delayed(clearTimeout, () {
removeCachedGif(path);
});
}
}