callAds method

void callAds({
  1. required String adId,
  2. String action = "default",
  3. required AdCallerInterface adCallerInterface,
})

Implementation

void callAds({
  required String adId,
  String action = "default",
  required AdCallerInterface adCallerInterface,
}) {
  InterstitialAd.load(
    adUnitId: adId,
    request: const AdRequest(),
    adLoadCallback: InterstitialAdLoadCallback(
      onAdLoaded: (InterstitialAd ad) {
        _interstitialAd = ad;
        dog.i("On Ad Loaded====>");
        AdLogger.logAd(
            action: action, provider: googleInterAdKey, status: adLoadedKey);
        _interstitialAd!.fullScreenContentCallback =
            FullScreenContentCallback(
              onAdShowedFullScreenContent: (InterstitialAd ad) {
                dog.i("On Ad Showed====>");
              },
              onAdDismissedFullScreenContent: (InterstitialAd ad) {
                adCallerInterface.onClose();
                dog.i("On Ad Dismissed====>");
                AdLogger.logAd(
                    action: action,
                    provider: googleInterAdKey, status: adDismissedKey);
                ad.dispose();
              },
              onAdFailedToShowFullScreenContent:
                  (InterstitialAd ad, AdError error) {
                AdLogger.logAd(action: action,
                    provider: googleInterAdKey,
                    status: adFailedKey);
                adCallerInterface.onError();
                dog.i("On Ad Failed====>");
                ad.dispose();
              },
            );
        adCallerInterface.onLoaded();
        _interstitialAd!.show();
      },
      onAdFailedToLoad: (LoadAdError error) {
        _interstitialAd = null;
        dog.i("On Ad Faield to Loade====> ${error.message}");
        AdLogger.logAd(action: action,
            provider: googleInterAdKey,
            status: adFailedToLoadKey);
        adCallerInterface.onError();
      },
    ),
  );
}