getCachedMediaPath static method
Returns cached path if present, otherwise null.
Implementation
static Future<String?> getCachedMediaPath(
String mediaUrl, {
String? cacheSubdirectory,
String? fileNamePrefix,
}) async {
try {
final mediaType = _getMediaType(mediaUrl);
final extension = _extractExtension(mediaUrl, mediaType);
final cacheDirectory = await _getCacheDirectory(cacheSubdirectory, createIfMissing: false);
if (cacheDirectory == null) {
return null;
}
final prefix = fileNamePrefix ?? 'media';
final file = File('${cacheDirectory.path}/${_buildFileName(mediaUrl, prefix, extension)}');
return await file.exists() ? file.path : null;
} catch (e) {
debugLog('Error getting cached media path: $e');
return null;
}
}