onUnlockFeaturePressed method

Future<void> onUnlockFeaturePressed()

Implementation

Future<void> onUnlockFeaturePressed() async {
  final product = await InAppPurchaseUtils.getProduct(productId());
  final subProduct = (subscriptionId() != null)
      ? await InAppPurchaseUtils.getProduct(subscriptionId()!)
      : null;

  if (product != null) {
    await showUnlockFeatureDialog(
      context,
      theme: theme,
      product: product,
      productSubscription: subProduct,
      hasSubscription: subProduct != null,
      onPurchasePressed: () {
        InAppPurchaseUtils.purchase(product);
      },
      onSubscriptionPressed: () {
        if (subProduct != null) {
          InAppPurchaseUtils.purchase(subProduct);
        }
      },
      onClosePressed: () {
        Navigator.pop(context);
      },
    );
  }
}