showPdaAd method

  1. @override
Widget showPdaAd({
  1. required Map<String, dynamic> ad,
  2. required String cliUbid,
  3. NativeAdType? adType,
  4. required double width,
  5. double? height,
  6. double? imageHeight,
  7. bool layoutHorizontal = false,
  8. double mediaRatio = 0.6,
  9. double? plaItemWidth,
  10. double? plaItemHeight,
  11. NativeAdStyle? plaCustomStyle,
  12. Widget? plaCustomCtaView,
  13. Widget? plaCustomBadgeView,
  14. String? plaAdLabelText,
  15. String? adLabelText,
  16. Alignment? adLabelAlignment,
  17. Widget? customCtaView,
  18. Widget? customBadgeView,
  19. NativeAdStyle? customStyle,
  20. void onAdClicked(
    1. Map<String, dynamic>
    )?,
  21. void onAdLoaded(
    1. Map<String, dynamic>
    )?,
  22. void onProductClicked(
    1. dynamic
    )?,
})
override

Creates a PDA (Product Display Ad) widget.

ad - Required ad data containing PDA information adType - Optional type of native ad (affects PLA layout) width - Required width of the PDA in logical pixels height - Optional height of the PDA in logical pixels imageHeight - Optional height of the media section layoutHorizontal - Optional horizontal layout (media left, PLA right). Default: false (vertical) mediaRatio - Optional media to PLA ratio for horizontal layout (0.0-1.0). Default: 0.6 plaItemWidth - Optional width of individual PLA items. Default: auto-calculated plaItemHeight - Optional height of individual PLA items. Default: auto-calculated plaCustomStyle - Optional custom styling for PLA items plaCustomCtaView - Optional custom CTA view for PLA items plaCustomBadgeView - Optional custom badge view for PLA items plaAdLabelText - Optional label text for PLA items cliUbid - Required client unique identifier for PLA tracking adLabelText - Optional label text displayed on the ad adLabelAlignment - Optional Flutter Alignment for the label text customCtaView - Optional custom call-to-action view customBadgeView - Optional custom badge view customStyle - Optional custom styling for the ad onAdClicked - Optional callback triggered when the ad is clicked onAdLoaded - Optional callback triggered when the ad loads onProductClicked - Optional callback triggered when a product is clicked

Returns a Widget that displays the PDA advertisement

Implementation

@override
Widget showPdaAd({
  required Map<String, dynamic> ad,
  required String cliUbid,
  NativeAdType? adType,
  required double width,
  double? height,
  double? imageHeight,
  bool layoutHorizontal = false,
  double mediaRatio = 0.6,
  double? plaItemWidth,
  double? plaItemHeight,
  NativeAdStyle? plaCustomStyle,
  Widget? plaCustomCtaView,
  Widget? plaCustomBadgeView,
  String? plaAdLabelText,
  String? adLabelText,
  Alignment? adLabelAlignment,
  Widget? customCtaView,
  Widget? customBadgeView,
  NativeAdStyle? customStyle,
  void Function(Map<String, dynamic>)? onAdClicked,
  void Function(Map<String, dynamic>)? onAdLoaded,
  void Function(dynamic)? onProductClicked,
}) {
  final alignment = adLabelAlignment ?? Alignment.topLeft;

  // Create custom style from parameters
  final customNativeStyle = PDAAdCustomStyle(
    nativeAdWidth: plaItemWidth,
    nativeAdHeight: plaItemHeight,
    nativeStyle: plaCustomStyle ?? customStyle,
    ctaButton: plaCustomCtaView ?? customCtaView,
    pdaProductStyle: layoutHorizontal
        ? PdaProductStyle.horizontal
        : PdaProductStyle.vertical,
    nativeAdAppear: onAdLoaded != null
        ? (nativeAd) => onAdLoaded(nativeAd.toMap())
        : null,
    nativeAdClicked: onAdClicked != null
        ? (nativeAd) => onAdClicked(nativeAd.toMap())
        : null,
  );

  // Create settings
  final settings = PDAAdSettings(
    width: width,
    height: height,
    adStyle: layoutHorizontal
        ? PdaProductStyle.horizontal
        : PdaProductStyle.vertical,
    adLabelText: plaAdLabelText ?? adLabelText,
    adLabelAlignment: alignment,
    badge: plaCustomBadgeView ?? customBadgeView,
    pdaAdCustomStyle: customNativeStyle,
  );

  return PdaAdView(
    ad: ad,
    config: _config,
    settings: settings,
    width: width,
    height: height,
    onAdClicked: onAdClicked,
    onAdLoaded: onAdLoaded,
    onProductClicked: onProductClicked,
  );
}