showInterstitialAd method

void showInterstitialAd()

Implementation

void showInterstitialAd() async {
  if (checkPlatform.isMobile) {
    if (_interstitialAd == null) {
      logCat('Warning: attempt to show interstitial before loaded.');
      //createInterstitialAd(showAfter: true);
      return;
    }
    _interstitialAd!.fullScreenContentCallback = FullScreenContentCallback(
      onAdShowedFullScreenContent: (InterstitialAd ad) => logCat('ad onAdShowedFullScreenContent.'),
      onAdDismissedFullScreenContent: (InterstitialAd ad) {
        logCat('$ad onAdDismissedFullScreenContent.');
        ad.dispose();
        createInterstitialAd();
      },
      onAdFailedToShowFullScreenContent: (InterstitialAd ad, AdError error) {
        logCat('$ad onAdFailedToShowFullScreenContent: $error');
        ad.dispose();
        createInterstitialAd();
      },
    );
    _interstitialAd!.show();
    _interstitialAd = null;
  }
}