copyWith method

SyncTask copyWith({
  1. SyncTaskStatus? status,
  2. int? attempts,
  3. DateTime? nextAttemptAt,
  4. DateTime? leaseUntil,
  5. String? leaseOwner,
  6. bool clearLease = false,
  7. String? lastError,
  8. bool clearLastError = false,
  9. int? lastStatusCode,
  10. bool clearLastStatusCode = false,
})

Returns a copy with the given fields replaced.

Nullable fields can be cleared with the matching clear* flag; clearLease clears both leaseUntil and leaseOwner.

Implementation

SyncTask copyWith({
  SyncTaskStatus? status,
  int? attempts,
  DateTime? nextAttemptAt,
  DateTime? leaseUntil,
  String? leaseOwner,
  bool clearLease = false,
  String? lastError,
  bool clearLastError = false,
  int? lastStatusCode,
  bool clearLastStatusCode = false,
}) => SyncTask(
  id: id,
  request: request,
  createdAt: createdAt,
  status: status ?? this.status,
  attempts: attempts ?? this.attempts,
  nextAttemptAt: nextAttemptAt ?? this.nextAttemptAt,
  leaseUntil: clearLease ? null : (leaseUntil ?? this.leaseUntil),
  leaseOwner: clearLease ? null : (leaseOwner ?? this.leaseOwner),
  lastError: clearLastError ? null : (lastError ?? this.lastError),
  lastStatusCode: clearLastStatusCode
      ? null
      : (lastStatusCode ?? this.lastStatusCode),
  tag: tag,
  dedupeKey: dedupeKey,
  metadata: metadata,
);