setNativeAd method

Future<bool> setNativeAd({
  1. String? adUnitId,
  2. String? factoryId,
  3. AdRequest? targetInfo,
  4. List<String>? keywords,
  5. String? contentUrl,
  6. bool? childDirected,
  7. List<String>? testDevices,
  8. bool? nonPersonalizedAds,
  9. bool? testing,
  10. MobileAdListener? listener,
  11. AdSize? size,
  12. double? anchorOffset,
  13. double? horizontalCenterOffset,
  14. 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,
  );
}