validateSavedEncryptedSetting function
- required MapSettings mapSettings,
- required bool isLoggedIn,
- required List<
Place> allPlaces,
Validates the saved encrypted places setting. Returns true if validation passed and encrypted places should be loaded.
Implementation
Future<bool> validateSavedEncryptedSetting({
required MapSettings mapSettings,
required bool isLoggedIn,
required List<Place> allPlaces,
}) async {
if (!mapSettings.showEncryptedPlaces) return false;
if (!isLoggedIn) {
// Not logged in, setting should be reset.
return false;
}
// Check if encrypted places are already loaded.
final hasEncryptedPlaces = allPlaces.any((p) => p.isEncrypted);
if (hasEncryptedPlaces) {
debugPrint(
'validateSavedEncryptedSetting: encrypted places already loaded, skipping',
);
return false;
}
// Check if security key is already available.
final hasKey = await EncryptedPlacesService.isSecurityKeyAvailable();
debugPrint(
'validateSavedEncryptedSetting: hasKey=$hasKey, will load encrypted places',
);
// Always return true to trigger loading (will prompt for key if needed)
return true;
}