show method

void show({
  1. required OnUserEarnedRewardCallback onUserEarnedReward,
})

Implementation

void show({required OnUserEarnedRewardCallback onUserEarnedReward}) {
  if (config.isInterstitial) {
    if (_rewardedInterstitialAd != null) {
      _rewardedInterstitialAd!.fullScreenContentCallback =
          FullScreenContentCallback(
        onAdShowedFullScreenContent: (ad) {},
        onAdDismissedFullScreenContent: (ad) {
          ad.dispose();
          _rewardedInterstitialAd = null;
          _loadAds();
        },
        onAdFailedToShowFullScreenContent: (ad, err) {
          ad.dispose();
          _rewardedInterstitialAd = null;
          _loadAds();
        },
      );

      _rewardedInterstitialAd!.show(onUserEarnedReward: onUserEarnedReward);
      _rewardedInterstitialAd = null;
    }
  } else {
    if (_rewardedAd != null) {
      _rewardedAd!.fullScreenContentCallback = FullScreenContentCallback(
        onAdShowedFullScreenContent: (ad) {},
        onAdDismissedFullScreenContent: (ad) {
          ad.dispose();
          _rewardedAd = null;
          _loadAds();
        },
        onAdFailedToShowFullScreenContent: (ad, err) {
          ad.dispose();
          _rewardedAd = null;
          _loadAds();
        },
      );

      _rewardedAd!.show(onUserEarnedReward: onUserEarnedReward);
      _rewardedAd = null;
    }
  }
}