|
|
@ -7,12 +7,12 @@ typedef APIImageDownloader = Future<Uint8List> Function(); |
|
|
|
class NeonCachedImage extends StatefulWidget { |
|
|
|
class NeonCachedImage extends StatefulWidget { |
|
|
|
const NeonCachedImage._({ |
|
|
|
const NeonCachedImage._({ |
|
|
|
required this.getImageFile, |
|
|
|
required this.getImageFile, |
|
|
|
|
|
|
|
required Key super.key, |
|
|
|
this.isSvgHint = false, |
|
|
|
this.isSvgHint = false, |
|
|
|
this.size, |
|
|
|
this.size, |
|
|
|
this.fit, |
|
|
|
this.fit, |
|
|
|
this.svgColor, |
|
|
|
this.svgColor, |
|
|
|
this.iconColor, |
|
|
|
this.iconColor, |
|
|
|
super.key, |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
factory NeonCachedImage.url({ |
|
|
|
factory NeonCachedImage.url({ |
|
|
@ -33,7 +33,7 @@ class NeonCachedImage extends StatefulWidget { |
|
|
|
fit: fit, |
|
|
|
fit: fit, |
|
|
|
svgColor: svgColor, |
|
|
|
svgColor: svgColor, |
|
|
|
iconColor: iconColor, |
|
|
|
iconColor: iconColor, |
|
|
|
key: key, |
|
|
|
key: key ?? Key(url), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
factory NeonCachedImage.api({ |
|
|
|
factory NeonCachedImage.api({ |
|
|
@ -46,10 +46,10 @@ class NeonCachedImage extends StatefulWidget { |
|
|
|
final Color? svgColor, |
|
|
|
final Color? svgColor, |
|
|
|
final Color? iconColor, |
|
|
|
final Color? iconColor, |
|
|
|
final Key? key, |
|
|
|
final Key? key, |
|
|
|
}) => |
|
|
|
}) { |
|
|
|
NeonCachedImage._( |
|
|
|
|
|
|
|
getImageFile: () async { |
|
|
|
|
|
|
|
final realKey = '${account.id}-$cacheKey'; |
|
|
|
final realKey = '${account.id}-$cacheKey'; |
|
|
|
|
|
|
|
return NeonCachedImage._( |
|
|
|
|
|
|
|
getImageFile: () async { |
|
|
|
final cacheFile = await _cacheManager.getFileFromCache(realKey); |
|
|
|
final cacheFile = await _cacheManager.getFileFromCache(realKey); |
|
|
|
if (cacheFile != null && cacheFile.validTill.isAfter(DateTime.now())) { |
|
|
|
if (cacheFile != null && cacheFile.validTill.isAfter(DateTime.now())) { |
|
|
|
return cacheFile.file.readAsBytes(); |
|
|
|
return cacheFile.file.readAsBytes(); |
|
|
@ -72,8 +72,9 @@ class NeonCachedImage extends StatefulWidget { |
|
|
|
fit: fit, |
|
|
|
fit: fit, |
|
|
|
svgColor: svgColor, |
|
|
|
svgColor: svgColor, |
|
|
|
iconColor: iconColor, |
|
|
|
iconColor: iconColor, |
|
|
|
key: key, |
|
|
|
key: key ?? Key(realKey), |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final Future<Uint8List> Function() getImageFile; |
|
|
|
final Future<Uint8List> Function() getImageFile; |
|
|
|
final bool isSvgHint; |
|
|
|
final bool isSvgHint; |
|
|
|