Skip to content

Instantly share code, notes, and snippets.

@kherel
Last active July 5, 2022 08:23
Show Gist options
  • Save kherel/55b6e2b9de1b57aa121604586fa356c9 to your computer and use it in GitHub Desktop.
Save kherel/55b6e2b9de1b57aa121604586fa356c9 to your computer and use it in GitHub Desktop.
Juan
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