问题描述
在执行 launchURL 之前加载我的广告。
buttonactionL: () async{
await StartApp.showInterstitialAd();
String url = "https://google.com";
_launchURL(url);
},
解决方法
调用showAds
方法并在完成onAdClosed
和onAdFailedToLoad
后执行launchURl
操作:
void showAds() {
_interstitialAd = InterstitialAd(
adUnitId: AdHelper.interstitialAdUnitId,request: AdRequest(),listener: AdListener(onAdLoaded: (ad) {
print("Ad Loaded");
showAds();
},onAdClosed: (ad) {
print("Closed Ad");
},onAdOpened: (ad) {
print("Opened Ad");
},onAdFailedToLoad: (ad,error) {
print("Failed to load Ad $error");
}),);
_interstitialAd.load();
}