QueueItem.fromMap constructor

QueueItem.fromMap(
  1. JsonMap map
)

Implementation

factory QueueItem.fromMap(JsonMap map) {
  return QueueItem(
    id: map['id'] as String? ?? '',
    createdAt: map['createdAt'] != null
        ? DateTime.tryParse(map['createdAt'] as String) ?? DateTime.now()
        : DateTime.now(),
    payload: map['payload'] is Map
        ? Map<String, dynamic>.from(map['payload'] as Map)
        : const {},
    retryCount: (map['retryCount'] as num?)?.toInt() ?? 0,
    nextRetryAt: map['nextRetryAt'] != null
        ? DateTime.tryParse(map['nextRetryAt'] as String)
        : null,
    idempotencyKey: map['idempotencyKey'] as String?,
    type: map['type'] as String?,
  );
}