deleteScopedImages function
Implementation
Future<void> deleteScopedImages(String scope) async {
final canonicalScope = _canonicalizeScope(scope.trim());
if (canonicalScope.isEmpty) return;
if (!kIsWeb) {
final base = await localPath;
await deleteScopedImageFilesAt(canonicalScope, base);
}
try {
final indexedImages = await imageIndexCollection.get();
if (indexedImages == null) return;
for (final entry in indexedImages.entries) {
final value = entry.value;
if (value is! Map) continue;
final indexedScope = _canonicalizeScope(value['scope']?.toString() ?? '');
final storedName =
_canonicalizeScopedName(value['storedName']?.toString() ?? '');
if (indexedScope == canonicalScope ||
storedName.startsWith('$canonicalScope/')) {
await imageIndexCollection.doc(entry.key.split('/').last).delete();
}
}
} catch (_) {}
}