createInterstitialAd method
Future
createInterstitialAd(
{ - bool showAfter = false,
})
Implementation
Future createInterstitialAd({bool showAfter = false}) async {
setShowProgressBar(show: true);
if (checkPlatform.isMobile) {
await InterstitialAd.load(
adUnitId: getInterstitielAdUnitId(),
request: request,
adLoadCallback: InterstitialAdLoadCallback(
onAdLoaded: (InterstitialAd ad) {
logCat('${ad.runtimeType} loaded.');
// _interstitialReady = true;
_interstitialAd = ad;
_numInterstitialLoadAttempts = 0;
_interstitialAd!.setImmersiveMode(true);
//ad.show();
setShowProgressBar(show: false);
},
onAdFailedToLoad: (LoadAdError error) {
logCat('InterstitialAd failed to load: $error.');
_numInterstitialLoadAttempts += 1;
_interstitialAd = null;
if (_numInterstitialLoadAttempts <= maxFailedLoadAttempts) {
createInterstitialAd();
}
},
));
if (showAfter) {
showInterstitialAd();
}
}
}