setBannerAd method
Future<bool>
setBannerAd({
- String? adUnitId,
- AdRequest? targetInfo,
- List<
String> ? keywords, - String? contentUrl,
- bool? childDirected,
- List<
String> ? testDevices, - bool? nonPersonalizedAds,
- bool? testing,
- MobileAdListener? listener,
- AdSize? size,
- double? anchorOffset,
- double? horizontalCenterOffset,
- AdErrorListener? errorListener,
Set the Banner Ad options.
Implementation
Future<bool> setBannerAd({
String? adUnitId,
AdRequest? targetInfo,
List<String>? keywords,
String? contentUrl,
bool? childDirected,
List<String>? testDevices,
bool? nonPersonalizedAds,
bool? testing,
m.MobileAdListener? listener,
AdSize? size,
double? anchorOffset,
double? horizontalCenterOffset,
// AnchorType anchorType,
m.AdErrorListener? errorListener,
}) {
// Can only have one instantiated Ads object.
if (!_firstObject) {
return Future.value(false);
}
if (listener != null) {
banner.eventListeners.add(listener);
}
_bannerAd ??= Banner(listener: banner);
banner.loadedListener = () {
bannerCompleter.complete(_bannerAd!._banner.ad as BannerAd);
};
banner.failedListener = (Ad ad, LoadAdError error) {
// completer.completeError(error);
};
if (adUnitId == null || adUnitId.isEmpty || adUnitId.length < 30) {
adUnitId = _bannerUnitId;
}
return _bannerAd!.set(
adUnitId: adUnitId,
targetInfo: targetInfo,
keywords: keywords ?? _keywords,
contentUrl: contentUrl ?? _contentUrl,
childDirected: childDirected ?? _childDirected,
testDevices: testDevices ?? _testDevices,
nonPersonalizedAds: nonPersonalizedAds ?? _nonPersonalizedAds,
testing: testing ?? _testing,
size: size ?? _size,
anchorOffset: anchorOffset ?? _anchorOffset,
horizontalCenterOffset: horizontalCenterOffset ?? _horizontalCenterOffset,
// anchorType: anchorType ?? _anchorType,
errorListener: errorListener ?? _errorListener,
);
}