removeOtpHistoryEntry method

Future<Map<String, dynamic>> removeOtpHistoryEntry({
  1. required String atSign,
  2. required String otp,
  3. required String generatedAtUtc,
})

Implementation

Future<Map<String, dynamic>> removeOtpHistoryEntry({
  required String atSign,
  required String otp,
  required String generatedAtUtc,
}) async {
  return mutateState(
    atSign: atSign,
    mutate: (state) {
      final history = _normalizeOtpHistory(state['otpHistory']);
      history.removeWhere(
        (entry) =>
            (entry['otp'] ?? '').toString() == otp &&
            (entry['generatedAtUtc'] ?? '').toString() == generatedAtUtc,
      );
      state['otpHistory'] = history;
    },
  );
}