AdsManager class

Centralized manager for configuring AdMob IDs, initializing Google Mobile Ads SDK, managing custom/house ads, handling GDPR/CPRA consent, coordinating full-screen ad presentation, and managing ad-free / premium status.

Properties

hashCode → int
The hash code for this object.
no setterinherited
initializationStatus → InitializationStatus?
no setter
isInitialized → bool
no setter
isShowingFullScreenAd ↔ bool
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

ensureInitialized() → Future<void>
Ensures AdsManager is initialized before proceeding with ad requests.
initialize({List<String>? testDeviceIds}) → Future<InitializationStatus>
Initializes the Google Mobile Ads SDK. testDeviceIds: Optional list of test device IDs to register for testing.
initializeAppOpenAd() → Future<void>
Initializes the App Open Ad lifecycle manager.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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

Static Properties

adEventStream → Stream<AdEvent>
Stream of all ad lifecycle and analytics events across all ad formats.
no setter
adsEnabledNotifier → ValueNotifier<bool>
final
customAds → List<CustomAdModel>
Currently configured custom / house ads.
no setter
enableNetworkCheck ↔ bool
Global toggle for network checking. Enabled by default.
getter/setter pair
hasCustomAds → bool
Whether custom / house ads have been registered via setupCustomAds.
no setter
instance → AdsManager
final
isAdsEnabled → bool
Whether ads are enabled globally. Set to false when user purchases "Remove Ads" / Premium.
no setter
onCustomAdClicked ↔ void Function(CustomAdModel ad)?
getter/setter pair
useTestAds ↔ bool
Whether to use official Google test ads instead of real ads.
getter/setter pair

Static Methods

canRequestAds() → Future<bool>
Checks if ads can be requested based on consent status.
clearCustomAds() → void
Clears registered custom ads.
createAdRequest({List<String>? keywords, String? contentUrl, bool? nonPersonalizedAds}) → AdRequest
Helper to create a standard AdRequest.
emitAdEvent(AdEvent event) → void
Internal dispatcher for emitting an ad event to both the listener callback and broadcast stream.
getCustomAd({int? index}) → CustomAdModel?
Retrieves a custom ad by index, or a random custom ad, or null if none registered.
hasCustomAdForFallback({CustomAdModel? customAd, dynamic customOfflineWidget, bool showOfflineFallback = true}) → bool
Determines if an ad format has any custom fallback ad available.
isPrivacyOptionsRequired() → Future<bool>
Checks if privacy options (revocation form) are required for this user.
onAdEvent(OnAdEventCallback callback) → void
Registers a global callback for receiving ad events (e.g. for Firebase Analytics logging).
removeAdEventListener() → void
Clears the global ad event listener callback.
requestConsent({ConsentDebugSettings? debugSettings}) → Future<ConsentResult>
Requests User Messaging Platform (UMP) GDPR / CPRA Consent.
reset() → void
Resets all global state (useful in automated tests or user sign-out flows).
resetConsent() → Future<void>
Resets consent state (useful for debug testing).
setAdsEnabled(bool enabled) → void
Enables or disables ads globally (e.g. for In-App Purchase "Remove Ads" / VIP users).
setAppOpenSuppressed(bool suppressed) → void
Temporarily suppresses or re-enables App Open ads (e.g. during onboarding or payment flows).
setRealAds({String? androidAppId, String? iosAppId, String? androidBanner, String? androidInterstitial, String? androidRewarded, String? androidRewardedInterstitial, String? androidNative, String? androidAppOpen, String? iosBanner, String? iosInterstitial, String? iosRewarded, String? iosRewardedInterstitial, String? iosNative, String? iosAppOpen, bool? useTestAds}) → void
Convenience method to configure both App IDs and Ad Unit IDs in a single call.
setRealAdUnitIds({String? androidBanner, String? androidInterstitial, String? androidRewarded, String? androidRewardedInterstitial, String? androidNative, String? androidAppOpen, String? iosBanner, String? iosInterstitial, String? iosRewarded, String? iosRewardedInterstitial, String? iosNative, String? iosAppOpen}) → void
Configures real/production Ad Unit IDs for all supported ad formats.
setRealAppIds({String? androidAppId, String? iosAppId}) → void
Configures real/production App IDs for Android and iOS.
setTestDeviceIds(List<String> testDeviceIds) → Future<void>
Registers test device IDs for AdMob test ad verification.
setupCustomAds(List<CustomAdModel> ads) → void
Configures custom ads (e.g. for offline fallbacks or house campaigns).
showPrivacyOptionsForm() → Future<FormError?>
Shows the Privacy Options Form for GDPR/CPRA consent modification.
updateRequestConfiguration({List<String>? testDeviceIds, int? tagForChildDirectedTreatment, int? tagForUnderAgeOfConsent, String? maxAdContentRating}) → Future<void>
Updates Google Mobile Ads request configuration (COPPA, Families Policy, test devices, content rating).