setVideoAd method
Future<bool>
setVideoAd({
- bool show = false,
- String? adUnitId,
- AdRequest? targetInfo,
- List<
String> ? keywords, - String? contentUrl,
- bool? childDirected,
- List<
String> ? testDevices, - bool? nonPersonalizedAds,
- bool? testing,
- MobileAdListener? listener,
- RewardListener? rewardListener,
- AdErrorListener? errorListener,
Video Ad
Set the Video Ad options.
Implementation
Future<bool> setVideoAd({
bool show = false,
String? adUnitId,
AdRequest? targetInfo,
List<String>? keywords,
String? contentUrl,
bool? childDirected,
List<String>? testDevices,
bool? nonPersonalizedAds,
bool? testing,
m.MobileAdListener? listener,
m.RewardListener? rewardListener,
m.AdErrorListener? errorListener,
}) {
// Can only have one instantiated Ads object.
if (!_firstObject) {
return Future.value(false);
}
if (listener != null) {
video.eventListeners.add(listener);
}
// Add this listener to the Error Listeners.
if (errorListener != null) {
m.eventErrorListeners.add(errorListener);
}
_videoAd ??= m.VideoAd(listener: video);
// Add an Reward function if any.
if (rewardListener != null) {
_videoAd!.rewardListener = rewardListener;
}
// If an unit id is not provided, it may be available from the constructor.
if (adUnitId == null || adUnitId.isEmpty || adUnitId.length < 30) {
adUnitId = _videoUnitId;
}
return _videoAd!.set(
adUnitId: adUnitId,
targetInfo: targetInfo,
keywords: keywords ?? _keywords,
contentUrl: contentUrl ?? _contentUrl,
childDirected: childDirected ?? _childDirected,
testDevices: testDevices ?? _testDevices,
nonPersonalizedAds: nonPersonalizedAds ?? _nonPersonalizedAds,
testing: testing ?? _testing,
errorListener: errorListener ?? _errorListener,
);
}