FFXPurchaseState.fromJson constructor

FFXPurchaseState.fromJson(
  1. Map<String, Object?> json
)

Implementation

FFXPurchaseState.fromJson(Map<String, Object?> json)
  : purchaseId = json['purchaseId'] as String,
    upgrade = json['upgrade'] == null
        ? null
        : FFXUpgrade._((json['upgrade'] as Map).cast<String, Object?>()),
    owned = {...(json['owned'] as List).cast<String>()},
    credits = json['credits'] == null
        ? null
        : FFXCredits._((json['credits'] as Map).cast<String, Object?>()),
    // A store or kind this SDK doesn't know is a newer backend's: an app
    // already in the stores skips that row rather than failing the read.
    purchases = [
      for (final item in json['purchases'] as List)
        ?FFXPurchase._from((item as Map).cast<String, Object?>()),
    ],
    products = [
      for (final item in (json['products'] as List?) ?? const [])
        ?FFXProduct._from((item as Map).cast<String, Object?>()),
    ];