showInterstitialAd method

Future<bool> showInterstitialAd({
  1. required String adUnitId,
})

Shows a preloaded interstitial ad for the given ad unit ID.

Returns true if the ad is shown successfully, false if no ad is loaded or if showing fails.

Make sure to preload an ad first using preloadInterstitialAd.

Implementation

Future<bool> showInterstitialAd({required String adUnitId}) async {
  try {
    final result = await _channel.invokeMethod<bool>(
      'showInterstitialAd',
      {'adUnitId': adUnitId},
    );
    return result ?? false;
  } catch (e) {
    debugPrint('Error showing interstitial ad: $e');
    return false;
  }
}