deletePlace static method
Implementation
static Future<bool> deletePlace(
String placeId,
BuildContext context,
Widget returnWidget,
) async {
try {
if (!authStateNotifier.value) return false;
final cm = PlacesCacheManager();
var existing = cm.podPlaces ?? await fetchPodPlaces();
final updated = List<Place>.from(existing)
..removeWhere((p) => p.id == placeId);
// Delete individual file and update main file in parallel.
final results = await Future.wait([
writePlacesJsonFile(
jsonEncode(updated.map((p) => p.toJson()).toList()),
),
deleteIndividualPlaceFile(placeId),
]);
final success = results[0];
if (success) {
await clearCache();
placesChangeNotifier.value++;
// Invalidate directory cache and notify file browser.
PodDirectoryService.invalidateCache('data/places');
PodDirectoryService.notifyChange();
}
return success;
} catch (_) {
return false;
}
}