Entitlement.fromMap constructor

Entitlement.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory Entitlement.fromMap(Map<String, dynamic> map) {
  return Entitlement(
    id: map['id'] as String,
    productId: map['productId'] as String,
    source: EntitlementSource.fromRawValue(map['source'] as String),
    isActive: map['isActive'] as bool,
    expiresAt: map['expiresAt'] != null
        ? DateTime.parse(map['expiresAt'] as String)
        : null,
    purchasedAt: DateTime.parse(map['purchasedAt'] as String),
    status: map['status'] as String?,
    pausedAt: map['pausedAt'] != null
        ? DateTime.parse(map['pausedAt'] as String)
        : null,
    pauseResumesAt: map['pauseResumesAt'] != null
        ? DateTime.parse(map['pauseResumesAt'] as String)
        : null,
    willRenew: map['willRenew'] as bool? ?? true,
    isTrial: map['isTrial'] as bool? ?? false,
    trialEndsAt: map['trialEndsAt'] != null
        ? DateTime.parse(map['trialEndsAt'] as String)
        : null,
    cancelledAt: map['cancelledAt'] != null
        ? DateTime.parse(map['cancelledAt'] as String)
        : null,
  );
}