Nikolas Rimikis
2 years ago
10 changed files with 62 additions and 57 deletions
@ -1,32 +0,0 @@
|
||||
part of '../../neon.dart'; |
||||
|
||||
typedef APIImageDownloader = Future<Uint8List> Function(); |
||||
|
||||
class NeonCachedApiImage extends NeonCachedImage { |
||||
NeonCachedApiImage({ |
||||
required final Account account, |
||||
required final String cacheKey, |
||||
required final APIImageDownloader download, |
||||
final String? etag, |
||||
super.size, |
||||
super.fit, |
||||
super.svgColor, |
||||
super.iconColor, |
||||
super.key, |
||||
}) : super( |
||||
getImageFile: () async { |
||||
final realKey = '${account.id}-$cacheKey'; |
||||
final cacheFile = await _cacheManager.getFileFromCache(realKey); |
||||
if (cacheFile != null && cacheFile.validTill.isAfter(DateTime.now())) { |
||||
return cacheFile.file; |
||||
} |
||||
|
||||
return _cacheManager.putFile( |
||||
realKey, |
||||
await download(), |
||||
maxAge: const Duration(days: 7), |
||||
eTag: etag, |
||||
); |
||||
}, |
||||
); |
||||
} |
@ -1,15 +0,0 @@
|
||||
part of '../../neon.dart'; |
||||
|
||||
class NeonCachedUrlImage extends NeonCachedImage { |
||||
NeonCachedUrlImage({ |
||||
required final String url, |
||||
super.size, |
||||
super.fit, |
||||
super.svgColor, |
||||
super.iconColor, |
||||
super.key, |
||||
}) : super( |
||||
getImageFile: () => _cacheManager.getSingleFile(url), |
||||
isSvgHint: Uri.parse(url).path.endsWith('.svg'), |
||||
); |
||||
} |
Loading…
Reference in new issue