saveAuth method
Persist token + reqId + timestamp
Implementation
Future<void> saveAuth({required String token, String? reqId}) async {
try {
final prefs = await SharedPreferences.getInstance();
await prefs.setString(_kTokenKey, token);
if (reqId != null && reqId.isNotEmpty) {
await prefs.setString(_kReqIdKey, reqId);
}
await prefs.setInt(
_kTokenSavedAtKey,
DateTime.now().millisecondsSinceEpoch,
);
} catch (e) {
// don't throw — caller should handle non-persistence gracefully
// but log for debugging
debugPrint?.call('AuthService.saveAuth: failed to persist auth: $e');
}
}