show method

void show({
  1. VoidCallback? doNext,
})

Show full screen loaded ads

Implementation

void show({VoidCallback? doNext}) {
  if (_interstitialAd != null) {
    _interstitialAd!.fullScreenContentCallback = FullScreenContentCallback(
      onAdShowedFullScreenContent: (InterstitialAd ad) {
        _requestedTimes = 0;
        doNext?.call();
      },
      onAdDismissedFullScreenContent: (InterstitialAd ad) {
        log('InterstitialAd.dismissed $ad', name: 'AdMob');
        ad.dispose();
        _interstitialAd = null;
        _loadAd();
      },
      onAdFailedToShowFullScreenContent: (InterstitialAd ad, AdError error) {
        log('InterstitialAd.failedShow $ad', error: error, name: 'AdMob');
        doNext?.call();
        ad.dispose();
        _interstitialAd = null;
      },
      onAdImpression: (ad) => log(
        'InterstitialAd.impression $ad',
        name: 'AdMob',
      ),
    );
    _interstitialAd!.show();
  } else {
    doNext?.call();
  }
}