dart-neats
dart-neats copied to clipboard
[retry] Add onAttempt callback to RetryOptions for logging
This PR for the retry package introduces a new optional onAttempt callback to the RetryOptions.retry() method. This callback is called on every retry attempt and receives the current attempt number. It is intended for logging, metrics, or instrumentation purposes without affecting the actual retry logic.
Existing behavior of fn() callbacks remains unchanged, ensuring full backward compatibility.
Example Usage
final r = RetryOptions(maxAttempts: 3);
await r.retry(
() async {
// Your retry logic here
},
onAttempt: (attempt) {
print('Attempt #$attempt');
},
);