cacheBytes method

  1. @override
Future<File> cacheBytes(
  1. String key,
  2. Uint8List bytes, {
  3. Duration maxAge = const Duration(days: 30),
  4. 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;
}