ad_flow library

Easy AdMob integration for Flutter.

ad_flow wraps google_mobile_ads into a testable, revenue-minded ad layer with policy-aware defaults: banner, interstitial, rewarded, rewarded interstitial, native and app open ads, plus UMP consent management.

This barrel exports the public API only. Internals live under src/.

Classes

AdBlocked
The slot is not PERMITTED to load right now — and here is why (3.0).
AdClickedEvent
The user clicked the ad.
AdController
Common surface of every ad controller.
AdDimensions
The on-screen size of a loaded view-based ad, in logical pixels.
AdDismissedEvent
The ad was dismissed by the user. The handle is now single-use spent: dispose it and load the next one.
AdFailed
The last load or show attempt failed.
AdFailedToShowEvent
The ad failed to show full-screen content.
AdFlow
The composition root and ergonomic entry point of ad_flow.
AdFlowBanner
Drop-in banner widget.
AdFlowConfig
Immutable top-level configuration for ad_flow.
AdFlowNativeAd
Drop-in native ad widget.
AdGate
The PERMISSION gate every controller consults: may this slot request (or keep serving) an ad right now?
AdIdle
No ad is loaded and no load is in flight.
AdImpressionEvent
An impression was recorded for the ad.
AdInspectorResult
Result of opening the Ad Inspector.
AdLoaded
An ad is loaded and ready to show.
AdLoading
A load request is in flight (including retry waits).
AdLoadState
The lifecycle state of an ad slot, exposed by every controller as a ValueListenable<AdLoadState>.
AdPaidEvent
Impression-level revenue reported by the SDK (allowlisted accounts only).
AdRequestConfig
Global request configuration applied once via MobileAds.updateRequestConfiguration's seam equivalent.
AdRequestOptions
Options applied to a single ad request.
AdResponseSummary
A compact, plugin-free summary of the SDK's ResponseInfo — which network actually filled the ad (2026-07 audit).
AdSdk
The seam between ad_flow and google_mobile_ads — the ONLY door to the plugin.
AdShowedEvent
The ad showed full-screen content.
AdShowing
A full-screen ad is currently on screen.
AnchoredAdaptiveSizeSpec
Anchored adaptive banner (the recommended default).
AppForegroundEvent
Emitted when the app returns to the foreground (warm start).
AppOpenAdController
Preloads and shows app open ads, enforcing Google's 4-hour expiry through the base engine's shared maxAdAge mechanism (the base timestamps every load and FullScreenAdControllerBase.show discards-and-reloads a stale ad instead of showing it).
AppOpenAdManager
The single owner of app-open behaviour (v1 trap: two reactors coordinated through statics fought each other — the facade creates exactly one manager and nothing else reacts to foreground).
AppOpenConfig
Configuration for the app open slot.
AppOpenHandle
A loaded app open ad.
AttExplainerContent
Copy for the ATT priming screen shown before Apple's system tracking prompt (iOS, client-driven ATT mode).
AttExplainerScreen
The optional ATT priming screen shown before Apple's system tracking prompt (iOS, client-driven ATT mode): explains, in the app's own words, what the next system dialog will ask.
BannerAdController
Loads and refreshes one banner slot.
BannerConfig
Configuration for the banner slot.
BannerHandle
A loaded banner ad.
BannerLoadSpec
Everything the seam needs to load one banner.
BannerSizeSpec
How a banner should be sized.
ConsentDebugOptions
Debug settings for UMP consent testing. Remove before release.
ConsentExplainerContent
Copy for the consent priming screen shown before the UMP GDPR form.
ConsentExplainerScreen
The optional consent priming screen shown before the UMP GDPR form: explains, in the app's own words, why consent is about to be requested.
ConsentGateway
Gathers user consent and answers the one question that gates every ad load: may ads be requested?
FixedSizeSpec
A fixed IAB banner size.
FrequencyCap
Limits how often full-screen ads in a slot may show.
FrequencyCapPolicy
Decides whether a full-screen slot may show another impression, and records impressions (per-slot caps + a global cross-format cap, ADR-009).
FullScreenAdController
Controllers for full-screen formats (interstitial, rewarded, rewarded interstitial, app open).
FullScreenAdControllerBase
Shared engine for all full-screen formats (interstitial, rewarded, rewarded interstitial, app open).
FullScreenAdCoordinator
Single source of truth for "is a full-screen ad on screen right now?".
FullScreenAdEvent
Events emitted by a full-screen ad handle between show() and disposal.
FullScreenAdHandle
A loaded full-screen ad (interstitial, rewarded, rewarded interstitial or app open), ready to be shown once.
InlineAdaptiveSizeSpec
Inline adaptive banner (for placement within scrolling content).
InMemoryKeyValueStore
In-memory KeyValueStore for tests (and consumers' tests).
InterstitialAdController
Preloads and shows interstitial ads at natural breaks.
InterstitialConfig
Configuration for the interstitial slot.
InterstitialHandle
A loaded interstitial ad.
KeyValueStore
Minimal persistence the policies need, behind an interface so tests use InMemoryKeyValueStore and consumers could swap the backend (ADR-P2).
MediationNetworkExtras
Extras for ONE third-party mediation network on an ad request, mapped to the plugin's MediationExtras mechanism (4.0).
NativeAdController
Loads one native ad slot (template or platform-factory rendering).
NativeConfig
Configuration for the native slot.
NativeHandle
A loaded native ad.
NativeLoadSpec
Everything the seam needs to load one native ad.
PlatformAdUnitId
A pair of per-platform ad unit IDs.
PrivacyOptionsButton
The persistent "Manage consent" entry point AdMob policy requires when getPrivacyOptionsRequirementStatus() is required (invariant 2).
RetryConfig
Tuning for load-failure retries (consumed by RetryPolicy).
RetryPolicy
Exponential backoff with jitter, a max attempt count and a cooldown (ADR-008). Pure math — the controllers own the timers.
RewardEarned
A reward earned from a rewarded or rewarded interstitial ad.
RewardedAdController
Preloads and shows rewarded ads.
RewardedConfig
Configuration for the rewarded slot.
RewardedHandle
A loaded rewarded ad.
RewardedInterstitialAdController
Preloads and shows rewarded interstitial ads — always behind the policy-mandated intro screen (ADR-013).
RewardedInterstitialConfig
Configuration for the rewarded interstitial slot.
RewardedInterstitialHandle
A loaded rewarded interstitial ad.
RewardedIntroScreen
The mandatory intro screen shown before a rewarded interstitial: clear reward messaging plus a skip option (AdMob policy — ADR-013).
RewardIntroContent
Copy for the mandatory rewarded-interstitial intro screen (reward disclosure + skip option — an AdMob policy requirement).
ServerSideVerification
Server-side verification options for (rewarded) ads with high-value rewards — echoed back in AdMob's server-to-server reward callback.
SharedPrefsKeyValueStore
KeyValueStore backed by shared_preferences (SharedPreferencesAsync).
StoredFrequencyCapPolicy
FrequencyCapPolicy implementation — memory-authoritative (4.0 audit).
TestAdUnitIds
Google's official sample ad unit IDs (safe to click; used by AdFlowConfig.test and whenever AdFlowConfig.testMode is on).
UmpConsentGateway
The production ConsentGateway: orchestrates the seam's UMP primitives.
ViewAdHandle
A loaded view-based ad (banner or native), hosted in the widget tree.

Enums

AdBlockReason
Why a load or show was refused (ADR-045).
AdConsentStatus
UMP consent status, mirrored above the seam.
AdFlowErrorKind
Classifies where in the ad pipeline an AdFlowError originated.
AdOrientation
Screen orientation used when resolving adaptive banner sizes.
AdPlatform
The mobile platform ads are served on. Injectable so tests and the facade never read global platform state directly.
AdRevenuePrecision
Precision of the revenue value reported in an AdPaidEvent.
AppOpenTriggerMode
When an app-open ad may be shown (5.1).
AttStatus
iOS App Tracking Transparency authorization status, mirrored above the seam. Only iOS 14+ ever reports the first four; every other platform (and older iOS) reports notSupported.
BannerKind
How a banner slot is sized.
CollapsiblePlacement
Where a collapsible banner anchors while expanded.
ConsentDebugGeography
Debug geography override for UMP testing.
FixedBannerSize
Fixed (non-adaptive) IAB banner sizes.
MaxContentRating
Maximum ad content rating, per AdMob's rating scale.
MediationConsentFailurePolicy
What happens to mediation-capable ad serving when the consent forwarding barrier (AdFlow.initialize's forwardConsent) could not be completed — the forwarder failed or timed out (release gate).
NativeTemplateKind
Built-in native ad template types (Dart-only rendering).
PrivacyOptionsRequirement
Whether a privacy-options entry point must be surfaced in the app.
RequestConfigFailurePolicy
What happens to ad loading when the SDK request configuration (updateRequestConfiguration: test devices, COPPA/under-age tags, max content rating) could not be applied — it failed, timed out, or SDK init never completed (4.0 audit).
ViewAdEvent
Events emitted by banner and native (view-based) ad handles.

Functions

adPlatformOf(TargetPlatform platform) AdPlatform
Maps a TargetPlatform to an AdPlatform.
asAdFlowError(Object error, AdFlowErrorKind fallbackKind) AdFlowError
Normalizes any thrown object into an AdFlowError of fallbackKind.
currentAdPlatform() AdPlatform
Resolves the current AdPlatform from defaultTargetPlatform.

Typedefs

AttExplainerPresenter = Future<void> Function(AttExplainerContent content)
Presents the ATT priming screen; completes when the primer is dismissed (Apple's system prompt always follows). Mirrors RewardedIntroPresenter.
ConsentExplainerPresenter = Future<void> Function(ConsentExplainerContent content)
Presents the consent priming screen; completes when the primer is dismissed (the real UMP form always follows, so there is nothing to return). Mirrors RewardedIntroPresenter.
OnUserEarnedReward = void Function(RewardEarned reward)
Callback invoked when the user earns a reward.
RewardedIntroPresenter = Future<bool> Function(RewardIntroContent content)
Presents the mandatory intro screen for a rewarded interstitial; resolves to whether the user chose to continue (false = skipped).

Exceptions / Errors

AdFlowError
A typed error surfaced by ad_flow.