loadRewardAd method

  1. @override
void loadRewardAd({
  1. AdModuleWithCallBacks? adModuleCallBacks,
})
override

Implementation

@override
void loadRewardAd({AdModuleWithCallBacks? adModuleCallBacks}) {
  RewardedAd.load(
    adUnitId: GlobalAdVariables.adNetworkIds!['google']!.rewardId!,
    request: const AdRequest(),
    rewardedAdLoadCallback: RewardedAdLoadCallback(
      onAdLoaded: (ad) {
        ad.fullScreenContentCallback = FullScreenContentCallback(
          onAdShowedFullScreenContent: (ad) {
            log("Google-Ad-Network->[Listener]->onAdShowedFullScreenContent");
          },
          onAdWillDismissFullScreenContent: (ad) {
            log("Google-Ad-Network->[Listener]->onAdWillDismissFullScreenContent");
          },
          onAdImpression: (ad) {
            log("Google-Ad-Network->[Listener]->onAdImpression");
          },
          onAdFailedToShowFullScreenContent: (ad, err) {
            log("Google-Ad-Network->[Listener]->onAdFailedToShowFullScreenContent");
            ad.dispose();
          },
          onAdDismissedFullScreenContent: (ad) {
            log("Google-Ad-Network->[Listener]->onAdDismissedFullScreenContent");

            ad.dispose();
            rewardedAd = null;
          },
          onAdClicked: (ad) {
            log("Google-Ad-Network->[Listener]->onAdClicked");
          },
        );
        rewardedAd = ad;
        if (adModuleCallBacks != null) {
          if (adModuleCallBacks.onAdLoaded != null) {
            adModuleCallBacks.onAdLoaded!();
          }
        }
      },
      onAdFailedToLoad: (error) {
        log(error.message.toString());
        if (adModuleCallBacks != null) {
          if (adModuleCallBacks.onLoadFailed != null) {
            adModuleCallBacks.onLoadFailed!();
          }
        }
      },
    ),
  );
}