show method

Future<AdReward?> show()

Shows the preloaded rewarded ad.

Returns AdReward if the user watched the ad to completion, or null if:

  • No ad is loaded
  • The user cancelled before completion

After a successful show, the next ad is automatically preloaded.

Implementation

Future<AdReward?> show() async {
  if (_isDisposed) return null;
  if (_state != AdState.ready) return null;

  _state = AdState.showing;
  final resolvedId = adUnitId.resolved(adType: AdType.rewarded);

  // In production, this would call rewardedAd.show() and wait for
  // the onUserEarnedReward callback.
  const reward = AdReward(amount: 1, type: 'reward');
  _emitEvent(AdEvent(type: AdEventType.shown, adUnitId: resolvedId));
  _emitEvent(AdEvent(
    type: AdEventType.rewardEarned,
    adUnitId: resolvedId,
    reward: reward,
  ));

  _state = AdState.idle;

  // Auto-preload next
  unawaited(load());
  return reward;
}