getContent method
Get content by identifier
If content exists and newly your duration, return content from cache/storage
If not, content will get before
If you will call same time and same identifier, feel free.
Because contentGetter only use once. Your other invokes wait first getter
Implementation
Future<T?> getContent(String identifier) async {
if (isThere(identifier)) {
var content = _contents[identifier];
if (content != null) {
if (content.cacheTime.difference(DateTime.now()).abs().inMilliseconds >
maxDuration.inMilliseconds) {
await update(identifier, checkAfterUpdate: false);
}
} else {
await update(identifier, checkAfterUpdate: false);
}
} else {
await update(identifier, checkAfterUpdate: false);
}
await _checkNeedsRemove();
return _contents[identifier];
}