createNativeAd method
Generate NativeAd with callback functions, then use this controller to create NativeAd widget.
For example:
myNative.load();
final AdWidget adWidget = AdWidget(ad: myNative);
final Container adContainer = Container(
alignment: Alignment.center,
child: adWidget,
width: 500,
height: 500,
);
Implementation
NativeAd createNativeAd({
Function()? onLoaded,
Function()? onLoadFailed,
}) =>
NativeAd(
adUnitId: nativeAdUnitId,
factoryId: nativeAdFactoryId,
request: const AdRequest(),
listener: NativeAdListener(
onAdLoaded: (ad) => onLoaded?.call(),
onAdFailedToLoad: (ad, error) {
onLoadFailed?.call();
loggingBuilder
?.call('Native Ad load failed error - ${error.toString()}');
},
),
);