initBannerAd static method

BannerAd? initBannerAd(
  1. Function onAdLoaded,
  2. Function onAdFailedToLoad
)

Implementation

static BannerAd? initBannerAd(
  Function onAdLoaded,
  Function onAdFailedToLoad,
) {
  if (isShowBanner == true) {
    return BannerAd(
      adUnitId: AdsInitialization.bannerId,
      size: AdSize.fullBanner,
      request: const AdRequest(),
      listener: BannerAdListener(
        onAdLoaded: (_) {
          onAdLoaded();
        },
        onAdFailedToLoad: (ad, error) {
          ad.dispose();
          onAdFailedToLoad();
        },
      ),
    )..load();
  } else {
    return null;
  }
}