appendOtpHistory method
Implementation
Future<Map<String, dynamic>> appendOtpHistory({
required String atSign,
required String otp,
String expiry = '',
String? expiresAtUtc,
}) async {
return mutateState(
atSign: atSign,
mutate: (state) {
final history = _normalizeOtpHistory(state['otpHistory']);
final entry = <String, dynamic>{
'otp': otp,
'expiry': expiry,
'generatedAtUtc': DateTime.now().toUtc().toIso8601String(),
};
if (expiresAtUtc != null && expiresAtUtc.trim().isNotEmpty) {
entry['expiresAtUtc'] = expiresAtUtc.trim();
}
history.insert(0, entry);
state['otpHistory'] = history;
},
);
}