Skip to content

Instantly share code, notes, and snippets.

@christianalfoni
Last active March 1, 2020 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save christianalfoni/790eaec80ee6f3d2feb07ff25dbd7902 to your computer and use it in GitHub Desktop.
Save christianalfoni/790eaec80ee6f3d2feb07ff25dbd7902 to your computer and use it in GitHub Desktop.
class AppleSubscription {
String productId;
int purchaseDate;
int expiresDate;
bool isActive;
AppleSubscription.fromJSON(Map<String, dynamic> json) :
productId = json["productId"],
purchaseDate = json["purchaseDate"],
expiresDate = json["expiresDate"],
isActive = json["isActive"];
}
/*
A Profile should have this data shape on the property "appleSubscriptions":
{20594975: {isActive: true, expiresDate: 1583082002000, productId: test, purchaseDate: 1583081702000}}
Where each key as an AppleSubscription
*/
appleSubscriptions = json["appleSubscriptions"] == null ? Map() : json['appleSubscriptions'];
/*
How do I convert this? I have tried every possible approach to casting, mapping to MapEntry etc. I am just not able
to convert it.
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment