deleteEncryptedPlace static method
- String placeId,
- BuildContext context,
- Widget child
Delete an encrypted place by ID. Ensures security key is available before modifying encrypted data.
Implementation
static Future<bool> deleteEncryptedPlace(
String placeId,
BuildContext context,
Widget child,
) async {
try {
// Ensure security key is available before fetching/modifying data.
if (_cachedEncryptedPlaces == null) {
if (!await ensureSecurityKey(context, child)) {
debugPrint(
'Security key not available, cannot safely delete encrypted place',
);
return false;
}
}
final existingPlaces =
_cachedEncryptedPlaces ?? await fetchEncryptedPlaces();
final updatedPlaces = existingPlaces
.where((p) => p.id != placeId)
.toList();
return await writeEncryptedPlaces(updatedPlaces, context, child);
} catch (e) {
debugPrint('Error deleting encrypted place: $e');
return false;
}
}