AdBanner constructor

AdBanner({
  1. required List<AdSize> adSizes,
  2. required XandrController controller,
  3. String? placementID,
  4. String? inventoryCode,
  5. Key? key,
  6. CustomKeywords? customKeywords,
  7. Duration autoRefreshInterval = const Duration(seconds: 30),
  8. bool resizeWhenLoaded = false,
  9. bool allowNativeDemand = false,
  10. Widget nativeAdBuilder(
    1. NativeAdData nativeAd
    )?,
  11. ClickThroughAction? clickThroughAction,
  12. bool resizeAdToFitContainer = false,
  13. bool? loadsInBackground,
  14. bool? shouldServePSAs,
  15. bool? enableLazyLoad,
  16. MultiAdRequestController? multiAdRequestController,
  17. LoadMode? loadMode,
  18. double? width,
  19. double? height,
  20. DoneLoadingCallback? onBannerFinishLoading,
  21. AdClickedCallback? onAdClicked,
})

Represents an ad banner widget.

This widget is used to display an advertisement banner. It can be customized with various properties to control the appearance and behavior of the ad.

Implementation

AdBanner({
  required this.adSizes,
  required this.controller,
  this.placementID,
  this.inventoryCode,
  super.key,
  this.customKeywords,
  this.autoRefreshInterval = const Duration(seconds: 30),
  this.resizeWhenLoaded = false,
  this.allowNativeDemand = false,
  this.nativeAdBuilder,
  this.clickThroughAction,
  this.resizeAdToFitContainer = false,
  this.loadsInBackground,
  this.shouldServePSAs,
  this.enableLazyLoad,
  this.multiAdRequestController,
  LoadMode? loadMode,
  double? width,
  double? height,
  this.onBannerFinishLoading,
  this.onAdClicked,
})  : assert(adSizes.isNotEmpty, 'adSizes must not be empty'),
      assert(
        placementID != null || inventoryCode != null,
        'placementID or inventoryCode must not be null',
      ),
      assert(
        (allowNativeDemand == false && nativeAdBuilder == null) ||
            (allowNativeDemand == true && nativeAdBuilder != null),
        'nativeAdBuilder must be set if allowNativeDemand is true',
      ),
      //Note: opensdk:auto_refresh_interval or
      // adview.setAutoRefreshInterval(long interval): The interval, in
      // milliseconds, at which the ad view will request new ads, if
      // autorefresh is enabled. The minimum period is 15 seconds. The default
      // period is 30 seconds. Set this to 0 to disable autorefresh.
      //Note: while the docs says its in milliseconds, seconds seems to be the
      // right unit.
      // see: https://learn.microsoft.com/en-us/xandr/mobile-sdk/show-banners-on-android
      assert(
        autoRefreshInterval.inSeconds == 0 ||
            autoRefreshInterval.inSeconds >= 15,
        'autoRefreshInterval must be either 0 seconds or >= 15 seconds',
      ),
      width = width ?? adSizes.first.width.toDouble(),
      height = height ?? adSizes.first.height.toDouble(),
      loadMode = loadMode ?? LoadMode.whenCreated();