set method

  1. @override
Future<void> set(
  1. String key,
  2. Uint8List value
)
override

Stores the given value associated with the key.

If the key already exists, its value is overwritten.

Implementation

@override
Future<void> set(String key, Uint8List value) async {
  final cache = await getApplicationCacheDirectory();
  final cacheDirectory = Directory('${cache.path}/cross_cache');

  if (!await cacheDirectory.exists()) {
    await cacheDirectory.create(recursive: true);
  }

  final filePathBytes = utf8.encode(key);
  final filePath = sha256.convert(filePathBytes).toString();

  final path = '${cacheDirectory.path}/$filePath';
  final file = File(path);
  await file.writeAsBytes(value);
}