setNativeAd method
Future<bool>
setNativeAd({
- String? adUnitId,
- String? factoryId,
- 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 Native Ad options.
Implementation
Future<bool> setNativeAd({
String? adUnitId,
String? factoryId,
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) {
native.eventListeners.add(listener);
}
_nativeAd ??= Native(listener: native);
if (adUnitId == null || adUnitId.isEmpty || adUnitId.length < 30) {
adUnitId = _nativeUnitId;
}
// For Setup Instructions:
/// https://pub.dev/packages/google_mobile_ads#native-ads
return _nativeAd!.set(
adUnitId: adUnitId,
factoryId: factoryId ?? _factoryId,
targetInfo: targetInfo,
keywords: keywords ?? _keywords,
contentUrl: contentUrl ?? _contentUrl,
childDirected: childDirected ?? _childDirected,
testDevices: testDevices ?? _testDevices,
nonPersonalizedAds: nonPersonalizedAds ?? _nonPersonalizedAds,
testing: testing ?? _testing,
anchorOffset: anchorOffset ?? _anchorOffset,
horizontalCenterOffset: horizontalCenterOffset ?? _horizontalCenterOffset,
// anchorType: anchorType ?? _anchorType,
errorListener: errorListener ?? _errorListener,
);
}