Implementation
static Future<List<PLYSubscription>> userSubscriptions() async {
final List<dynamic> result =
await _channel.invokeMethod('userSubscriptions');
final List<PLYSubscription> subscriptions = new List.empty(growable: true);
result.forEach((element) {
final List<PLYPlan?> plans = new List.empty(growable: true);
element['product']['plans']
.forEach((k, plan) => plans.add(transformToPLYPlan(plan)));
subscriptions.add(PLYSubscription(
element['purchaseToken'],
PLYSubscriptionSource.values[element['subscriptionSource']],
element['nextRenewalDate'],
element['cancelledDate'],
transformToPLYPlan(element['plan']),
PLYProduct(element['product']['name'], element['product']['vendorId'],
plans.whereNotNull().toList())));
});
return subscriptions;
}