get method
Gets a cached item with the given key
Implementation
T? get(String key) {
if (_cache == null) {
return null;
}
final CacheItem<T>? cacheItem =
_cache!.firstWhereOrNull((element) => element.key == key);
// If there is no item cached
if (cacheItem == null) {
return null;
}
// If the items cache duration is over
if (_isItemOutdated(cacheItem)) {
remove(key);
return null;
}
return cacheItem.item;
}