showConfirmAdDialog method

Future<ResponseInterstitialRewarded> showConfirmAdDialog(
  1. Widget dialog,
  2. BuildContext context
)

Shows a confirmation dialog, if user confirms the ad is shown. The confirmation dialog is not shown in case the ad is not loaded.

The returned ResponseInterstitialRewarded details the ourtcome.

Call fetchAd before calling this method.

Implementation

Future<ResponseInterstitialRewarded> showConfirmAdDialog(
    Widget dialog, BuildContext context) async {
  _log('Preparing confirm dialog ...');

  /// The completer may indicate failed loading in [fetchAd].
  if (_completer.isCompleted == false) {
    if (_adToShow == null) {
      _log('ad is NULL, early abort');
      _completer.complete(ResponseInterstitialRewarded(
          StatusInterstitialRewarded.notLoadedGenerally));
    } else {
      _log('Confirm dialog ...');

      await showDialog<StatusInterstitialRewarded>(
        context: context,
        builder: (_) => dialog,

        // DialogConfirmAd(showNoAd: () {
        //   _log('showNoAd(), completing with: displayDeniedByUser');
        //   _completer.complete(ResponseInterstitialRewarded(
        //       StatusInterstitialRewarded.displayDeniedByUser));
        // }, showAd: () {
        // _log('showAd()');
        // _adToShow?.show(
        //   onUserEarnedReward: (AdWithoutView view, RewardItem rewardItem) {
        //     _log('  - onUserEarnedReward');
        //     _rewardItem = rewardItem;
        //   },
        // );
        // }),
      );
    }
  }
  return _completer.future;
}