showInterstitialRewarded method

Future<ResponseInterstitialRewarded> showInterstitialRewarded(
  1. BuildContext context, {
  2. String? adUnitId,
})

Returns a ResponseInterstitialRewarded which informs about the rewarded dialog.

Implementation

Future<ResponseInterstitialRewarded> showInterstitialRewarded(
    BuildContext context,
    {String? adUnitId}) async {
  if (isDisabled()) {
    return ResponseInterstitialRewarded(
        StatusInterstitialRewarded.displayDeniedProgrammatically);
  }

  if (_interstitialRewardedMap[adUnitId] == null &&
      _interstitialRewardedMap.isEmpty) {
    return ResponseInterstitialRewarded(
        StatusInterstitialRewarded.notLoadedAdIdNotSet);
  }

  adUnitId ??= _interstitialRewardedMap.keys.first;
  final result =
      await _interstitialRewardedMap[adUnitId]!.showConfirmAdDialog(context);
  _interstitialRewardedMap[adUnitId]!.fetchAd(); // no await
  return result;
}