getFlow method
Future<AdaptyFlow>
getFlow({
- required String placementId,
- @Deprecated('Has no effect for flows. Starting Adapty SDK 4.0.0 the locale is applied when the flow view is built — ' 'pass it to AdaptyUI.createFlowView or AdaptyUIFlowPlatformView instead.') String? locale,
- AdaptyFlowFetchPolicy? fetchPolicy,
- 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.locale: has no effect. Starting with 4.0.0 a flow is localized when its view is built, so pass the locale toAdaptyUI.createFlowVieworAdaptyUIFlowPlatformViewinstead.fetchPolicy: by default SDK will try to load data from server and will return cached data in case of failure. Otherwise use.returnCacheDataElseLoadto return cached data if it exists.loadTimeout: the timeout for the paywall loading.
Returns:
- the AdaptyFlow object. This model contains the list of the products ids, flow’s identifier, custom payload, and several other properties.
Implementation
Future<AdaptyFlow> getFlow({
required String placementId,
@Deprecated(
'Has no effect for flows. Starting Adapty SDK 4.0.0 the locale is applied when the flow view is built — '
'pass it to AdaptyUI.createFlowView or AdaptyUIFlowPlatformView instead.',
)
String? locale,
AdaptyFlowFetchPolicy? fetchPolicy,
Duration? loadTimeout,
}) {
_warnIfFlowLocalePassed(locale, 'getFlow');
return _invokeMethod<AdaptyFlow>(
Method.getFlow,
(data) {
final flowMap = data as Map<String, dynamic>;
return AdaptyFlowJSONBuilder.fromJsonValue(flowMap);
},
{
Argument.placementId: placementId,
if (locale != null) Argument.locale: locale,
if (fetchPolicy != null) Argument.fetchPolicy: fetchPolicy.jsonValue,
if (loadTimeout != null) Argument.loadTimeout: loadTimeout.inMilliseconds.toDouble() / 1000.0,
},
);
}