configure method
void
configure({
- required Set<
String> productIds, - required OnPurchaseDetailsReceived onDetailsFetched,
- dynamic onError(
- dynamic error
override
Configures the in-app purchase system. IMPORTANT! You must subscribe to this stream as soon as your app launches,
Retrieves product details and sets up purchase handling.
Required parameters:
productIds
Set of product identifiers to fetch details for.onDetailsFetched
Callback function called when products are fetched.
Implementation
@override
void configure(
{required Set<String> productIds,
required OnPurchaseDetailsReceived onDetailsFetched,
Function(dynamic error)? onError}) {
_productIds.addAll(productIds);
_subscription = _inAppPurchase.purchaseStream.listen((purchaseDetails) {
onDetailsFetched(purchaseDetails);
_purchases.addAll(purchaseDetails);
}, onDone: () {
_subscription.cancel();
}, onError: (error) {
if (kDebugMode) {
onError?.call('$error');
log('Error: $error');
}
});
}