Last active
July 5, 2022 08:23
-
-
Save kherel/55b6e2b9de1b57aa121604586fa356c9 to your computer and use it in GitHub Desktop.
Juan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() async { | |
var plan = myPlanFunction(); | |
print(plan['title']); | |
} | |
dynamic myPlanFunction() { | |
dynamic plan; | |
if (currentSubscription['productId'] == null) { | |
plan = dersuSubscriptionProducts.firstWhere( | |
(e) => e['subscriptionId'] == currentSubscription['subscriptionId'], | |
); | |
} else { | |
plan = dersuSubscriptionProducts.firstWhere( | |
(e) => | |
e['subscriptionId'] == currentSubscription['subscriptionId'] && | |
e['productId'] == currentSubscription['productId'], | |
); | |
} | |
return plan; | |
} | |
var currentSubscription = { | |
'subscriptionId': 'pro', | |
'productId': null, | |
}; | |
var dersuSubscriptionProducts = [ | |
{ | |
'subscriptionId': 'pro', | |
'productId': 'a_pro', | |
'title': 'real pro with annual payment', | |
}, | |
{ | |
'subscriptionId': 'pro', | |
'productId': null, | |
'title': 'pro for investors', | |
}, | |
{ | |
'subscriptionId': 'pro', | |
'productId': 'a_pro', | |
'title': 'real pro with monthly payment', | |
} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment