get method

  1. @override
Future<Uint8List> get(
  1. String key
)
override

Retrieves the value associated with the key.

Throws an exception if the key is not found.

Implementation

@override
Future<Uint8List> get(String key) async {
  final cache = await getApplicationCacheDirectory();
  final filePathBytes = utf8.encode(key);
  final filePath = sha256.convert(filePathBytes).toString();
  final file = File('${cache.path}/cross_cache/$filePath');

  if (await file.exists()) {
    return await file.readAsBytes();
  } else {
    throw FileSystemException('File not found', file.path);
  }
}