showAdIfAvailable method

void showAdIfAvailable(
  1. String requestId
)

Shows the rewarded ad if it is available.

Does nothing if the ad is not available or already being shown.

Implementation

void showAdIfAvailable(String requestId) {
  if (!isAdAvailable) {
    _logger.debug('Tried to show ad before it was available.');

    return;
  }

  _rewardedAd!.show(onUserEarnedReward: (ad, reward) {
    handleUserEarnedReward(requestId, ad, reward);
  });
}