get method

  1. @override
Future<Uint8List?> get({
  1. required String key,
})
override

Retrieves the data cached under the spefied key if available, null otherwise.

Implementation

@override
Future<Uint8List?> get({required String key}) async {
  CacheDetails? details = _internalCache[key];

  if(details == null) {
    return null;
  }

  final timestamp = details.timestamp;
  final int maxAge = details.maxAge;

  final int currentTime = DateTime.now().millisecondsSinceEpoch;

  if(currentTime - timestamp <= maxAge) {
    return base64.decode(details.content!);
  }
  else {
    _internalCache.remove(key);
  }

  return null;
}