Skip to main content
Version: v1.1.0

Events & errors

Ads report their lifecycle through listener objects. Callbacks run on the Flutter UI isolate, and each is optional.

Callbacks by format​

CallbackBannerInterstitialRewardedNative
onAdLoaded✓✓✓✓ (with the response)
onAdDisplayed✓✓✓
onAdFailed(String)✓✓✓✓
onAdClicked✓✓✓✓
onAdClosed✓✓✓
onAdExpired✓✓✓✓
onAdImpressionMediationMediationMediation✓
onUserEarnedReward(PrebidReward)✓
  • Banner onAdClosed fires when a click-through (in-app browser or modal) is dismissed.
  • onAdImpression comes from the ad SDK in the AdMob and MAX companions. Prebid-rendered banners and fullscreen ads fire Prebid's impression trackers but don't report a callback. Native ads report it from viewability (see Native).
  • onAdExpired fires when the bid's exp elapses before the ad is shown; load again.

Banner video playback has its own PrebidBannerVideoListener; GAM, AdMob and MAX native have their own listeners, documented on their pages.

Errors​

Load, show and render failures are not thrown. They arrive through onAdFailed with the native SDK's message:

PrebidInterstitialAdListener(
onAdFailed: (error) => debugPrint('Interstitial failed: $error'),
)

Common causes:

Message / codeCause
No bids / prebidDemandNoBidsThe auction returned no bid for this config ID.
The ad is not loadedshow() was called before onAdLoaded, or after the ad was shown.
No Activity is attached… / No view controller…show() with the app in the background.
The Prebid SDK is not initialized / prebidSdkNotInitializedA load before initializeSdk completed (Android).
Timeout / prebidDemandTimedOutThe auction exceeded setTimeoutMillis.

Other calls (setters, fetchDemand, loadAd) return Futures. They complete once the native side has applied the call and only fail when the platform call itself fails, for example a PlatformException when the plugin isn't registered in a test. fetchDemand of the Original API reports the auction outcome through its resultCode.