teads_flutter_mocks library
Test doubles for package:teads_flutter's injectable interfaces.
Import this separately from package:teads_flutter/teads_flutter.dart —
deliberately not re-exported from there, so production code never pulls
in test scaffolding. Install a mock by assigning it to the corresponding
static .instance:
TeadsSdk.instance = MockTeadsSdk();
TeadsPrivacy.instance = MockTeadsPrivacy();
Recommendations.instance = MockRecommendations(recommendations: [...]);
final interstitial = MockInterstitial(); // constructed directly, not via .instance
MockInterstitial stands in for an Interstitial your own code
constructs and holds — InterstitialPlacement itself has no injectable
instance to swap, since it isn't a singleton the way TeadsSdk/
TeadsPrivacy/Recommendations are. MockBannerController extends the
concrete BannerController (not just BannerApi), so it substitutes
directly into BannerPlacement.controller for a widget test, unlike the
other mocks here which stand in for an interface. There is no Media mock:
Media has no injectable interface — see docs/integration-usage.md's
section on "Depending on an interface" for why.
FeedPlacement is different again: it has no injectable interface and
never will (it builds its own real WebViewController internally, and
webview_flutter's platform view cannot run in flutter test at all).
MockFeedPlacement mirrors its constructor/callbacks exactly instead, and
FeedPlacementBuilder is the seam that lets a test substitute one for the
other — see both types' doc comments.
Classes
- BannerApi
- The Banner contract, for consumers that want to depend on an interface rather than BannerController directly — e.g. a publisher's own Clean Architecture layer holding this behind its own infrastructure adapter.
- FeedPlacement
- Hosts the SmartFeed bridge page in a Flutter-owned WebView and speaks the bridge protocol directly, with no native Teads SDK.
- FeedPlacementConfig
- Placement-level configuration for a Dart-driven SmartFeed.
- Interstitial
- The Interstitial contract, for consumers that want to depend on an interface rather than InterstitialPlacement directly — e.g. a publisher's own Clean Architecture layer holding this behind its own infrastructure adapter.
- MockBannerController
-
A test double for BannerController, with no
MethodChannelinvolved. - MockFeedPlacement
- A test double for FeedPlacement, with no real WebView/platform view involved — entirely standalone; FeedPlacement itself is untouched.
- MockFeedPlacementState
- MockInterstitial
-
A test double for Interstitial, with no
MethodChannelinvolved. - MockRecommendations
-
A test double for RecommendationsApi, with no
MethodChanneland no network call involved. - MockTeadsPrivacy
-
A test double for TeadsPrivacyApi, with no
MethodChannelinvolved. - MockTeadsSdk
-
A test double for TeadsSdkApi, with no
MethodChannelinvolved. - Recommendations
- Fetches content recommendations.
- RecommendationsApi
-
The Recommendations contract, for consumers that want to depend on an
interface rather than Recommendations's statics directly — e.g. a
publisher's own Clean Architecture layer holding this behind its own
infrastructure adapter, or
MockRecommendations(package:teads_flutter/teads_flutter_mocks.dart) in a test. - RecommendationsPlacementConfig
- Configuration for a Recommendations.fetch request.
- TeadsAdClick
-
Payload for a TeadsAdEvent.clicked or TeadsAdEvent.clickedOrganic
event.
urlis null for a plain TeadsAdEvent.clicked on platforms/ placements that don't report a click-through URL. - TeadsAdError
-
Payload for a TeadsAdEvent.failed event, and for Feed's
onUnsupported— a parity gap or page-reported error, not necessarily an ad-load failure, but the same "just a diagnostic reason string" shape. - TeadsPrivacy
- Publisher-supplied privacy overrides, for apps whose CMP does not write the IAB keys itself.
- TeadsPrivacyApi
- The TeadsPrivacy contract, for consumers that want to depend on an interface rather than TeadsPrivacy's statics directly — e.g. a publisher's own Clean Architecture layer holding this behind its own infrastructure adapter.
- TeadsRecommendation
- A single recommended content item, as returned by Recommendations.fetch.
- TeadsRecommendationDisclosure
- The "Ad Choices"-style disclosure icon for an RTB recommendation.
- TeadsRecommendationThumbnail
- A thumbnail image attached to a TeadsRecommendation.
- TeadsSdk
- Entry point for the Teads SDK.
- TeadsSdkApi
- The TeadsSdk contract, for consumers that want to depend on an interface rather than TeadsSdk's statics directly — e.g. a publisher's own Clean Architecture layer holding this behind its own infrastructure adapter.
Enums
- TeadsAdEvent
- Native placement lifecycle events, shared across every placement — Media, Banner and Interstitial wrap native's own event stream directly; Feed (pure Dart) maps the bridge's widget-event names onto the same vocabulary instead, since it speaks the bridge protocol directly rather than wrapping a native placement.
Extensions
Typedefs
-
FeedPlacementBuilder
= Widget Function({required FeedPlacementConfig config, Key? key, double? maxHeight, void onEvent(TeadsAdEvent event, Map<
String, dynamic> ? data)?, void onFullScreenChange(bool fullScreen)?, void onOrganicClick(Uri organicUrl)?, void onUnsupported(TeadsAdError error)?}) -
A builder for either the real FeedPlacement or
MockFeedPlacement(package:teads_flutter/teads_flutter_mocks.dart) — both have this exact parameter shape, so a constructor tear-off of either (FeedPlacement.new/MockFeedPlacement.new) is directly assignable to this type.