buyNonConsumable method

Future<bool> buyNonConsumable({
  1. required PurchaseParam purchaseParam,
})

Buy a non consumable product or subscription.

Non consumable items can only be bought once. For example, a purchase that unlocks a special content in your app. Subscriptions are also non consumable products.

You always need to restore all the non consumable products for user when they switch their phones.

This method does not return the result of the purchase. Instead, after triggering this method, purchase updates will be sent to purchaseStream. You should Stream.listen to purchaseStream to get PurchaseDetails objects in different PurchaseDetails.status and update your UI accordingly. When the PurchaseDetails.status is PurchaseStatus.purchased, PurchaseStatus.restored or PurchaseStatus.error you should deliver the content or handle the error, then call completePurchase to finish the purchasing process.

This method does return whether or not the purchase request was initially sent successfully.

Consumable items are defined differently by the different underlying payment platforms, and there's no way to query for whether or not the ProductDetail is a consumable at runtime.

See also:

Calling this method for consumable items will cause unwanted behaviors!

Implementation

Future<bool> buyNonConsumable({required PurchaseParam purchaseParam}) =>
    InAppPurchasePlatform.instance.buyNonConsumable(
      purchaseParam: purchaseParam,
    );