storeImage method
Store an image to disk.
Implementation
Future<String?> storeImage({
required int id,
required String type,
required String content,
String mediaType = 'image/png',
}) async {
if (type != 'image') return null;
try {
final dir = _getSessionImageStoreDir();
await Directory(dir).create(recursive: true);
final imagePath = _getImagePath(id, mediaType);
await File(imagePath).writeAsBytes(base64Decode(content));
_evictOldestIfAtCap();
_storedImagePaths[id] = imagePath;
_logForDebugging('Stored image $id to $imagePath');
return imagePath;
} catch (error) {
_logForDebugging('Failed to store image: $error');
return null;
}
}