cacheBytes method
Future<File>
cacheBytes(
- String key,
- Uint8List bytes, {
- Duration maxAge = const Duration(days: 30),
- String fileExtension = 'jpg',
override
Implementation
@override
Future<File> cacheBytes(
String key,
Uint8List bytes, {
Duration maxAge = const Duration(days: 30),
String fileExtension = 'jpg',
}) async {
// Check if the image file is not in the cache
final fileInfo = await _cacheManager.getFileFromCache(key);
final file = fileInfo?.file;
if (file == null) {
// Put the image file in the cache
final files = await _cacheManager.putFile(
key,
bytes,
maxAge: maxAge,
fileExtension: fileExtension,
);
return files;
}
return file;
}