AdBanner constructor
AdBanner({
- required List<
AdSize> adSizes, - required XandrController controller,
- String? placementID,
- String? inventoryCode,
- Key? key,
- CustomKeywords? customKeywords,
- Duration autoRefreshInterval = const Duration(seconds: 30),
- bool resizeWhenLoaded = false,
- bool allowNativeDemand = false,
- Widget nativeAdBuilder(
- NativeAdData nativeAd
- ClickThroughAction? clickThroughAction,
- bool resizeAdToFitContainer = false,
- bool? loadsInBackground,
- bool? shouldServePSAs,
- bool? enableLazyLoad,
- MultiAdRequestController? multiAdRequestController,
- LoadMode? loadMode,
- double? width,
- double? height,
- DoneLoadingCallback? onBannerFinishLoading,
- 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();