receiveURL method
Implementation
Future<String?> receiveURL(String storageURL,
{bool useCaching = true, bool storeInCache = true}) async {
// try getting the download link from persistency
if (useCaching) {
try {
persistentKeyValueStore ??= await SharedPreferences.getInstance();
final String? cachedURL =
persistentKeyValueStore!.getString(storageURL);
if (cachedURL != null) {
return cachedURL;
}
} on Exception catch (error, stackTrace) {
print(error);
print(stackTrace);
}
}
// if downloadLink is null get it from the storage
try {
final String downloadLink =
await _storageInstance.ref().child(storageURL).getDownloadURL();
// cache link
if (useCaching || storeInCache) {
await persistentKeyValueStore!.setString(storageURL, downloadLink);
}
// give url to caller
return downloadLink;
} on Exception {
// print(error);
// print(stackTrace);
}
return null;
}