FakeAdNetworkAdapter class

A scriptable in-memory AdNetworkAdapter for tests.

Configure behaviour through the mutable fields (they may be changed between calls) and inspect the recorded calls afterwards.

final admob = FakeAdNetworkAdapter(AdNetwork.admob)..loadError = noFill;
await UnifiedAds.init(config, adapters: [admob]);
Inheritance

Constructors

FakeAdNetworkAdapter(AdNetwork network, {Set<AdFormat>? supportedFormats, TestModeSupport testModeSupport = TestModeSupport.flag, bool requiresAdUnitId = true, AdError? initError, Duration initDelay = Duration.zero, AdError? loadError, Duration loadDelay = Duration.zero, AdError? showError, RewardItem reward = const RewardItem(amount: 10, type: 'coins'), bool autoCloseOnShow = false, AdError? bannerError, Size bannerSize = const Size(320, 50), bool respondToBanners = true})
Creates a fake for network supporting banner, interstitial and rewarded unless supportedFormats says otherwise.

Properties

autoCloseOnShow ↔ bool
Whether show also emits a closed event.
getter/setter pair
bannerError ↔ AdError?
When set, banners fail with this error.
getter/setter pair
bannerRequests → List<BannerRequest>
Banner requests received.
final
bannerSize ↔ Size
Size reported for banners.
getter/setter pair
bannerViewType → String
Platform-view type registered by the adapter's native banner factory, dev.arovyx.plugin.unifiedads/<network>/banner.
no setteroverride
consents → List<ConsentState>
Consent states received.
final
destroyed → List<AdHandle>
Handles passed to destroy.
final
disposeCalls ↔ int
Number of dispose calls.
getter/setter pair
events → Stream<AdEvent>
Stream of events for every ad of this adapter. Must stay listenable after dispose, because a re-initialized session subscribes again.
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
initDelay ↔ Duration
Delay before initialize completes.
getter/setter pair
initError ↔ AdError?
When set, initialize fails with this error.
getter/setter pair
initializeCalls ↔ int
Number of initialize calls.
getter/setter pair
lastConfig ↔ NetworkConfig?
Config passed to the last initialize call.
getter/setter pair
lastTestMode ↔ bool?
Test-mode flag passed to the last initialize call.
getter/setter pair
loadCalls → List<({String adUnitId, AdFormat format})>
Every load call.
final
loadDelay ↔ Duration
Delay before load completes.
getter/setter pair
loadError ↔ AdError?
When set, load fails with this error.
getter/setter pair
network → AdNetwork
The network this adapter serves.
final
requiresAdUnitId → bool
Whether loads need a per-format ad-unit / placement ID. Networks keyed only by an app ID (Start.io) return false.
final
respondToBanners ↔ bool
Whether banners answer automatically (in a microtask) after their creation parameters are requested.
getter/setter pair
reward ↔ RewardItem
Reward emitted when a rewarded ad is shown.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
showError ↔ AdError?
When set, show fails with this error.
getter/setter pair
shown → List<AdHandle>
Handles passed to successful show calls.
final
supportedFormats → Set<AdFormat>
Formats this adapter can load. Empty for documented stubs.
final
testModeSupport → TestModeSupport
How far initialize's testMode flag is honoured.
final

Methods

applyConsent(ConsentState state) → Future<void>
Forwards privacy signals to the SDK. May be called before initialize.
override
bannerCreationParams(BannerRequest request) → Map<String, Object?>
Creation parameters passed to the native banner view for request.
override
destroy(AdHandle handle) → Future<void>
Releases a loaded ad that will not be shown.
override
dispose() → Future<void>
Releases all ads and native resources. Safe to call more than once; initialize may be called again afterwards (re-init, hot restart).
override
emit(AdEvent event) → void
Emits event on events.
initialize(NetworkConfig config, {required bool testMode}) → Future<AdResult<void>>
Initializes the SDK. Idempotent; calling it again with the same config is a no-op.
override
isReady(AdHandle handle) → bool
Whether handle is loaded, unexpired and not yet shown.
override
load(AdFormat format, String adUnitId) → Future<AdResult<AdHandle>>
Loads a full-screen ad of format.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
respondToBanner(String adId) → void
Emits the configured banner outcome for adId (loaded + sized, or failed).
show(AdHandle handle) → Future<AdResult<void>>
Shows a previously loaded ad. Completes when the ad is presented (or failed to present), not when it is closed.
override
simulateClick(AdHandle handle) → void
Emits a click for handle.
simulateClose(AdHandle handle) → void
Emits a close for handle.
toString() → String
A string representation of this object.
inherited

Operators

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