_nativeAd = NativeAd(
adUnitId: _adUnitId,
factoryId: "myNativeAdFactory",
nativeAdOptions: NativeAdOptions(
adChoicesPlacement: AdChoicesPlacement.bottomRightCorner,
mediaAspectRatio: MediaAspectRatio.any, //portrait, any
requestCustomMuteThisAd: true,
videoOptions: VideoOptions(
clickToExpandRequested: false,
customControlsRequested: true,
)),
listener: NativeAdListener(onAdLoaded: (ad) {
Logger.instance.info(message: '$NativeAd loaded.');
setState(() {
_nativeAdIsLoaded = true;
});
}, onAdFailedToLoad: (ad, error) {
// Dispose the ad here to free resources.
Logger.instance.warn(message: '$NativeAd failed to load: $error');
ad.dispose();
}, onAdImpression: (ad) {
Logger.instance.info(message: '$NativeAd impression achieved.');
}, onAdClosed: (ad) {
Logger.instance.debug(message: '$NativeAd ad closed.');
}),
request: const AdRequest(),
)..load();