updateEncryptedPlace static method
- Place updatedPlace,
- BuildContext context,
- Widget child
Update an encrypted place. Ensures security key is available before modifying encrypted data.
Implementation
static Future<bool> updateEncryptedPlace(
Place updatedPlace,
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 update encrypted place',
);
return false;
}
}
final existingPlaces =
_cachedEncryptedPlaces ?? await fetchEncryptedPlaces();
final updatedPlaces = existingPlaces.map((p) {
return p.id == updatedPlace.id ? updatedPlace : p;
}).toList();
return await writeEncryptedPlaces(updatedPlaces, context, child);
} catch (e) {
debugPrint('Error updating encrypted place: $e');
return false;
}
}