fetchSubscriptionItems method
Future<void>
fetchSubscriptionItems(
)
Implementation
Future<void> fetchSubscriptionItems() async {
try {
// Fetch the subscription items from the store using the subscription IDs.
_subscriptionItems = await FlutterInappPurchase.instance
.getSubscriptions(_subscriptionIds);
// Sort the subscription items in the order of their IDs.
_subscriptionItems.sort((a, b) => _subscriptionIds
.indexOf(a.productId!)
.compareTo(_subscriptionIds.indexOf(b.productId!)));
if (kDebugMode) {
print(_subscriptionItems);
}
} catch (e) {
// Log an error if fetching subscription items fails.
if (kDebugMode) {
print("Failed to fetch subscription items: $e");
}
}
}