showFullScreenAd method

Future<bool> showFullScreenAd({
  1. String? adUnitId,
  2. AdRequest? targetInfo,
  3. List<String>? keywords,
  4. String? contentUrl,
  5. bool? childDirected,
  6. List<String>? testDevices,
  7. bool? testing,
  8. MobileAdListener? listener,
  9. double? anchorOffset,
  10. double? horizontalCenterOffset,
  11. AdErrorListener? errorListener,
  12. State<StatefulWidget>? state,
})

Show a Full Screen Ad.

parameters: state is passed to determine if the app is not terminating. No need to show ad. anchorOffset is the logical pixel offset from the edge of the screen (default 0.0) anchorType place advert at top or bottom of screen (default bottom)

Implementation

Future<bool> showFullScreenAd({
  String? adUnitId,
  AdRequest? targetInfo,
  List<String>? keywords,
  String? contentUrl,
  bool? childDirected,
  List<String>? testDevices,
  bool? testing,
  m.MobileAdListener? listener,
  double? anchorOffset,
  double? horizontalCenterOffset,
//    AnchorType? anchorType,
  m.AdErrorListener? errorListener,
  State? state,
}) async {
  // Return true only if the attempt was successful.
  bool show = false;

  // state is passed to determine if the app is not terminating. No need to show ad.
  if (state != null && !state.mounted) {
    return show;
  }

  // Can only have one instantiated Ads object.
  if (!_firstObject) {
    return show;
  }

  if (_fullScreenAd == null || !_fullScreenAd!.loaded) {
    show = await setFullScreenAd(
      adUnitId: adUnitId,
      keywords: keywords,
      contentUrl: contentUrl,
      childDirected: childDirected,
      testDevices: testDevices,
      testing: testing,
      anchorOffset: anchorOffset,
      horizontalCenterOffset: horizontalCenterOffset,
//        anchorType: anchorType,
      listener: listener,
      errorListener: errorListener,
    );

    if (show) {
      show = _fullScreenAd!.show();
    }
  } else {
    if (listener != null) {
      screen.eventListeners.add(listener);
    }

    // Add this listener to the Error Listeners.
    if (errorListener != null) {
      m.eventErrorListeners.add(errorListener);
    }
    show = _fullScreenAd!.show();
  }
  return show;
}