ad_flow_testing library
Test doubles for apps that unit-test their ad integration — and the internals they are built from: the SDK seam's handles, events and load specs, the full-screen controller engine, and the collaborators (gate, frequency caps, coordinator, retry policy) for tests that build a controller by hand. App code never needs these.
Import in test files only, next to the main library:
import 'package:ad_flow/ad_flow.dart';
import 'package:ad_flow/ad_flow_testing.dart';
final sdk = FakeAdSdk()..canRequestAdsResult = true;
final ads = await AdFlow.initialize(config, sdk: sdk, ...);
Classes
- AdClickedEvent
- The user clicked the ad.
- 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.
- AdFailedToShowEvent
- The ad failed to show full-screen content.
- AdGate
- The PERMISSION gate every controller consults: may this slot request (or keep serving) an ad right now?
- AdImpressionEvent
- An impression was recorded for the ad.
- AdInspectorResult
- Result of opening the Ad Inspector.
- 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.
- AnchoredAdaptiveSizeSpec
- Anchored adaptive banner (the recommended default).
- AppForegroundEvent
- Emitted when the app returns to the foreground (warm start).
- AppOpenHandle
- A loaded app open ad.
- BannerHandle
- A loaded banner ad.
- BannerHeightMemory
- Remembers how tall anchored adaptive banners actually rendered, per requested width.
- 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.
- ConsentUpdateCall
- One recorded FakeAdSdk.requestConsentInfoUpdate call.
- FakeAdSdk
- A fully controllable AdSdk test double.
- FakeBannerHandle
- A drivable fake banner handle. buildWidget returns a SizedBox of size so widget tests can pump it without platform views.
- FakeFullScreenAdHandle
- A drivable fake full-screen ad handle.
- FakeNativeHandle
- A drivable fake native handle. buildWidget returns a fixed-size SizedBox so widget tests can pump it without platform views.
- FixedSizeSpec
- A fixed IAB banner size.
- FrequencyCapPolicy
- Decides whether a full-screen slot may show another impression, and records impressions (per-slot caps + a global cross-format cap, ADR-009).
- 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).
- InterstitialHandle
- A loaded interstitial ad.
- MediationNetworkExtras
-
Extras for ONE third-party mediation network on an ad request, mapped to
the plugin's
MediationExtrasmechanism (4.0). - NativeHandle
- A loaded native ad.
- NativeLoadSpec
- Everything the seam needs to load one native ad.
- 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.
- RewardedHandle
- A loaded rewarded ad.
- RewardedInterstitialHandle
- A loaded rewarded interstitial ad.
- ServerSideVerification
- Server-side verification options for (rewarded) ads with high-value rewards — echoed back in AdMob's server-to-server reward callback.
- StoredFrequencyCapPolicy
- FrequencyCapPolicy implementation — memory-authoritative (4.0 audit).
- ViewAdHandle
- A loaded view-based ad (banner or native), hosted in the widget tree.
Enums
- AdConsentStatus
- UMP consent status, mirrored above the seam.
- AdOrientation
- Screen orientation used when resolving adaptive banner sizes.
- AdRevenuePrecision
- Precision of the revenue value reported in an AdPaidEvent.
- AnchoredBannerSize
- Which of Google's anchored adaptive banner sizes to request.
- 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.
- 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.
- NativeTemplateKind
- Built-in native ad template types (Dart-only rendering).
- PrivacyOptionsRequirement
- Whether a privacy-options entry point must be surfaced in the app.
- ViewAdEvent
- Events emitted by banner and native (view-based) ad handles.
Functions
-
resetAppOpenLaunchOpportunity(
) → void -
Resets the process-global one-shot App Open cold-launch latch used by
AppOpenAdManager.showAtLaunch— call in testsetUpso tests do not leak the consumed latch into each other. Test-only; NOT part of the production API (package:ad_flow/ad_flow.dartnever exposes it).
Typedefs
- OnUserEarnedReward = void Function(RewardEarned reward)
- Callback invoked when the user earns a reward.