deleteArticlePhotos method
Implementation
@action
Future<bool> deleteArticlePhotos(
{required String localPhotoFolderPath}) async {
try {
if (photos.isNotEmpty) {
final temp =
photos.map((e) => ArticlePhoto.fromMap(e.toMap())).toList();
for (final photo in temp) {
await _articlesService.deleteForeverPhotoRpc.request(photo);
}
photos.clear();
}
if (localPhotoFolderPath.isNotEmpty &&
Directory(localPhotoFolderPath).existsSync() &&
Directory(localPhotoFolderPath).listSync().isNotEmpty) {
for (final file in Directory(localPhotoFolderPath).listSync()) {
File(file.path).deleteSync();
}
}
return true;
} on FileSystemException catch (e) {
print(e);
return false;
}
}