void loadNative() async {
NativeAd(
slotCode: 'slot-code-xxxxxx',
request: const AdRequest(),
nativeTemplate: NativeTemplate(
templateType: TemplateType.medium,
cornerRadius: 8,
mainBackgroundColor: Colors.white,
primaryTextStyle: const NativeTextStyle(
textColor: Colors.black,
backgroundColor: Colors.white,
style: NativeTextFontStyle.monospace,
size: 16,
),
secondaryTextStyle: const NativeTextStyle(
textColor: Colors.black,
backgroundColor: Colors.white,
style: NativeTextFontStyle.monospace,
size: 16,
),
tertiaryTextStyle: const NativeTextStyle(
textColor: Colors.black,
backgroundColor: Colors.white,
style: NativeTextFontStyle.monospace,
size: 16,
),
callToActionTextStyle: const NativeTextStyle(
textColor: Colors.black,
backgroundColor: Colors.white,
style: NativeTextFontStyle.monospace,
size: 16,
),
callToActionBackgroundColor: Colors.blue,
),
listener: NativeAdListener(
onLoaded: (ad) {
setState(() => _nativeAd = ad);
},
onFailed: (ad, errorCode) {
if (errorCode == 'NO_FILL') {
setState(() => _nativeAd = ad);
return;
}
ad.dispose();
},
onOpened: (ad) {},
onClosed: (ad) {},
onImpression: (ad) {},
onClicked: (ad) {},
onWillDismissScreen: (ad) {},
),
).load();
}