createFlowView method

Future<AdaptyUIFlowView> createFlowView({
  1. required AdaptyFlow flow,
  2. String? locale,
  3. String? customLayoutId,
  4. Duration? loadTimeout,
  5. bool preloadProducts = false,
  6. bool androidEnableSafeArea = true,
  7. Map<String, String>? customTags,
  8. Map<String, DateTime>? customTimers,
  9. Map<String, AdaptyCustomAsset>? customAssets,
  10. Map<AdaptyProductIdentifier, AdaptyPurchaseParameters>? productPurchaseParams,
})

Right after receiving AdaptyFlow, you can create the corresponding AdaptyUIFlowView to present it afterwards.

Parameters

  • flow: an AdaptyFlow object, for which you are trying to get a controller.
  • locale: the identifier of the localization to render the flow with, e.g. en, es, fr. If you don't pass it, the view is rendered in en, falling back to the flow's default localization when the flow has no en. Asking for a localization the flow does not have falls back to the flow default as well, without an error. Strings missing from the chosen localization are filled in from the default one.
  • customLayoutId: the custom ID of a grid configured for this flow in the Adapty Flow Builder, to render instead of the grid selected automatically for the current device. Pass null to keep the automatic selection. The ID is matched exactly as given; an unknown ID fails with an AdaptyError.
  • preloadProducts: If you pass true, AdaptyUI will automatically prefetch the required products at the moment of view assembly.
  • androidEnableSafeArea: Android only. If true, the flow view applies the safe-area insets as paddings. Has no effect on iOS. Defaults to true.
  • productPurchaseParams: A map that contains purchase parameters for specific products. The key is an AdaptyProductIdentifier and the value is AdaptyPurchaseParameters containing purchase-specific configuration.

Returns

Implementation

Future<AdaptyUIFlowView> createFlowView({
  required AdaptyFlow flow,
  String? locale,
  String? customLayoutId,
  Duration? loadTimeout,
  bool preloadProducts = false,
  bool androidEnableSafeArea = true,
  Map<String, String>? customTags,
  Map<String, DateTime>? customTimers,
  Map<String, AdaptyCustomAsset>? customAssets,
  Map<AdaptyProductIdentifier, AdaptyPurchaseParameters>? productPurchaseParams,
}) async {
  return Adapty()._invokeMethod<AdaptyUIFlowView>(
    Method.createFlowView,
    (data) {
      final viewMap = data as Map<String, dynamic>;
      return AdaptyUIFlowViewJSONBuilder.fromJsonValue(viewMap);
    },
    {
      Argument.flow: flow.jsonValue,
      if (locale != null) Argument.locale: locale,
      if (customLayoutId != null) Argument.customLayoutId: customLayoutId,
      Argument.preloadProducts: preloadProducts,
      Argument.enableSafeAreaPaddings: androidEnableSafeArea,
      if (loadTimeout != null) Argument.loadTimeout: loadTimeout.inMilliseconds.toDouble() / 1000.0,
      if (customTags != null) Argument.customTags: customTags,
      if (customTimers != null)
        Argument.customTimers: customTimers.map((key, value) => MapEntry(
              key,
              value.toAdaptyValidString(),
            )),
      if (customAssets != null)
        Argument.customAssets: customAssets.entries
            .map((entry) => {
                  Argument.id: entry.key,
                  ...entry.value.jsonValue,
                })
            .toList(),
      if (productPurchaseParams != null)
        Argument.productPurchaseParameters: AdaptyProductIdentifier.convertProductPurchaseParamsToJson(
          productPurchaseParams,
        ),
    },
  );
}