show method
Shows the ad. Show failures are reported via contentEvents as AdFailedToShowEvent, mirroring the underlying SDK.
onUserEarnedReward is required by rewarded and rewarded interstitial
ads and ignored by the other formats.
Implementation
@override
Future<void> show({OnUserEarnedReward? onUserEarnedReward}) async {
showCalls++;
lastOnUserEarnedReward = onUserEarnedReward;
final rejectsWith = showRejectsWith;
if (rejectsWith != null) throw rejectsWith;
if (showCalls > 1) {
// A real single-use ad instance can't be shown a second time — fail
// the way the SDK would (via the event stream, matching the
// documented AdSdk.show contract) instead of silently succeeding
// again. Catches a controller bug that reaches a double-show
// through a path review finding #10's own repro didn't cover.
_content.add(
const AdFailedToShowEvent(
AdFlowError(AdFlowErrorKind.showFailed, 'Ad already used'),
),
);
return;
}
final error = showError;
if (error != null) {
_content.add(AdFailedToShowEvent(error));
return;
}
if (autoEmitShowed) _content.add(const AdShowedEvent());
}