getSingleLocalInterstitialAd static method

DreamInterstitialAd getSingleLocalInterstitialAd(
  1. String localKey,
  2. String unitId
)

Get single local interstitial ad

Implementation

static DreamInterstitialAd getSingleLocalInterstitialAd(
  String localKey,
  String unitId,
) {
  final existingAd = _interstitialAdMap[localKey];
  if (existingAd != null) {
    return existingAd;
  }

  final networkType = AdNetworkDetector.detectNetworkType(unitId);
  DreamInterstitialAd interAd;

  switch (networkType) {
    case AdNetworkType.admob:
      interAd = AdMobDreamInterstitialAd(
        config: AdFullScreenConfig(
          isEnable: true,
          firstLoadAsync: 1,
          ids: [unitId],
        ),
        tag: localKey,
      );
      break;
    case AdNetworkType.gam:
      // GAM will be implemented later
      interAd = AdMobDreamInterstitialAd(
        config: AdFullScreenConfig(
          isEnable: true,
          firstLoadAsync: 1,
          ids: [unitId],
        ),
        tag: localKey,
      );
      break;
    case AdNetworkType.applovinMax:
      // AppLovin Max will be implemented later
      interAd = AdMobDreamInterstitialAd(
        config: AdFullScreenConfig(
          isEnable: true,
          firstLoadAsync: 1,
          ids: [unitId],
        ),
        tag: localKey,
      );
      break;
  }

  _interstitialAdMap[localKey] = interAd;
  return interAd;
}