getPaywall method

Future<AdaptyPaywall> getPaywall({
  1. required String placementId,
  2. String? locale,
  3. AdaptyPaywallFetchPolicy? fetchPolicy,
  4. Duration? loadTimeout,
})

Adapty allows you remotely configure the products that will be displayed in your app. This way you don’t have to hardcode the products and can dynamically change offers or run A/B tests without app releases.

Read more on the Adapty Documentation

Parameters:

  • placementId: the identifier of the desired placement. This is the value you specified when you created the placement in the Adapty Dashboard.

Returns:

  • the AdaptyPaywall object. This model contains the list of the products ids, paywall’s identifier, custom payload, and several other properties.

Implementation

Future<AdaptyPaywall> getPaywall({required String placementId, String? locale, AdaptyPaywallFetchPolicy? fetchPolicy, Duration? loadTimeout}) async {
  final result = (await _invokeMethodHandlingErrors<String>(Method.getPaywall, {
    Argument.placementId: placementId,
    if (locale != null) Argument.locale: locale,
    if (fetchPolicy != null) Argument.fetchPolicy: json.encode(fetchPolicy.jsonValue),
    if (loadTimeout != null) Argument.loadTimeout: loadTimeout.inMilliseconds.toDouble() / 1000.0,
  })) as String;
  return AdaptyPaywallJSONBuilder.fromJsonValue(json.decode(result));
}