GoogleAdsHelper class

Main Google Ads Helper class - Singleton instance for managing all ad types

This is the core class that handles initialization, loading, and showing of all ad types. Use GoogleAdsHelper.instance to access the singleton instance.

Example:

await GoogleAdsHelper.instance.initialize(
  rewardedAdUnitId: 'your-rewarded-ad-unit-id',
);

GoogleAdsHelper.instance.loadRewardedAd();
GoogleAdsHelper.instance.showRewardedAd(
  onRewardEarned: (reward) => print('Earned!'),
);

Properties

adStates Map<String, AdState>
Get current ad states
no setter
hashCode int
The hash code for this object.
no setterinherited
interstitialCallCount int
Get current interstitial call count
no setter
interstitialShowEveryCount int
Get interstitial show frequency
no setter
isBannerLoading bool
Get loading states
no setter
isBannerReady bool
Check if ads are available
no setter
isInterstitialLoading bool
no setter
isInterstitialReady bool
no setter
isNativeLoading bool
no setter
isNativeReady bool
no setter
isRewardedLoading bool
no setter
isRewardedReady bool
no setter
onAdClosed ↔ dynamic Function(String)?
getter/setter pair
onAdError ↔ dynamic Function(String)?
getter/setter pair
onAdLoaded ↔ dynamic Function(String)?
getter/setter pair
onAdShown ↔ dynamic Function(String)?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
willInterstitialShowOnNextCall bool
Check if interstitial will show on next call
no setter

Methods

dispose() → void
Dispose all ads
getBannerAd() → BannerAd?
Get banner ad instance
getNativeAd() → NativeAd?
Get native ad instance
initialize({String? bannerAdUnitId, String? interstitialAdUnitId, String? rewardedAdUnitId, String? nativeAdUnitId, List<String>? testDeviceIds, dynamic onAdError(String)?, dynamic onAdLoaded(String)?, dynamic onAdShown(String)?, dynamic onAdClosed(String)?}) Future<void>
Initialize the ads manager with your custom ad IDs
loadAllAds() → void
Load all ad types that have been configured
loadBannerAd() → void
Load banner ad
loadInterstitialAd() → void
Load interstitial ad
loadNativeAd() → void
Load native ad
loadRewardedAd() → void
Load rewarded ad
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reloadAllAds() → void
Force reload all ads
reloadBannerAd() → void
Reload specific ad type
reloadInterstitialAd() → void
reloadNativeAd() → void
reloadRewardedAd() → void
resetInterstitialCount() → void
Reset interstitial call count manually
setInterstitialFrequency(int count) → void
Set custom interstitial show frequency count - Show interstitial every N calls (default is 3)
showInterstitialAd({VoidCallback? onInterstitialShown, VoidCallback? onAdClosed, VoidCallback? onAdFailedToShow, bool forceShow = false}) bool
Show interstitial ad with count-based control and custom callbacks
showRewardedAd({dynamic onRewardEarned(RewardItem)?, VoidCallback? onAdClosed, VoidCallback? onAdFailedToShow}) bool
Show rewarded ad with custom callbacks
toString() String
A string representation of this object.
inherited
updateAdUnitIds({String? bannerAdUnitId, String? interstitialAdUnitId, String? rewardedAdUnitId, String? nativeAdUnitId}) → void
Update ad unit IDs at runtime

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

instance GoogleAdsHelper
no setter