openWebPaywall method

Future<void> openWebPaywall({
  1. AdaptyFlowPaywall? paywall,
  2. AdaptyPaywallProduct? product,
  3. AdaptyWebPresentation openIn = AdaptyWebPresentation.externalBrowser,
})

Implementation

Future<void> openWebPaywall({
  AdaptyFlowPaywall? paywall,
  AdaptyPaywallProduct? product,
  AdaptyWebPresentation openIn = AdaptyWebPresentation.externalBrowser,
}) async {
  Map<String, dynamic>? arguments = {Argument.openIn: openIn.jsonValue};

  if (paywall != null) {
    arguments[Argument.paywall] = paywall.jsonValue;
  } else if (product != null) {
    arguments[Argument.product] = product.jsonValue;
  } else {
    throw AdaptyError(
      'Either paywall or product parameter must be provided',
      AdaptyErrorCode.wrongParam,
      null,
    );
  }

  return _invokeMethod<void>(
    Method.openWebPaywall,
    (data) => null,
    arguments,
  );
}