withIdempotencyKey method
options with this task's idempotency key added as the header.
The key is the same on every attempt, so a server that supports
idempotency keys can ignore a retried request it already handled.
Returns options unchanged (or empty options) when the task has no
idempotency key.
Implementation
Options withIdempotencyKey(
Options? options, {
String header = defaultIdempotencyHeader,
}) {
final base = options ?? Options();
final key = idempotencyKey;
if (key == null) return base;
return base.copyWith(headers: {...?base.headers, header: key});
}