getCooldownState method
Implementation
Future<LivenessDetectionCooldown> getCooldownState() async {
final prefs = await SharedPreferences.getInstance();
final cooldownJson = prefs.getString(_cooldownKey);
if (cooldownJson == null) {
return const LivenessDetectionCooldown();
}
final cooldown = LivenessDetectionCooldown.fromJson(
jsonDecode(cooldownJson),
);
// Check if cooldown has expired
if (cooldown.isInCooldown &&
cooldown.remainingCooldownTime.inSeconds <= 0) {
return await _resetCooldown();
}
return cooldown;
}