preloadInterstitialAd method
Preloads an interstitial ad for the given ad unit ID.
adUnitId - The ad unit ID for the interstitial ad.
requestConfig - Optional configuration for the ad request.
Returns true if the ad loads successfully, false otherwise.
Example:
final success = await ads.preloadInterstitialAd(
adUnitId: 'ca-app-pub-xxxxx/xxxxx',
);
Implementation
Future<bool> preloadInterstitialAd({
required String adUnitId,
AdRequestConfig? requestConfig,
}) async {
_validateAdUnitId(adUnitId);
try {
final params = <String, dynamic>{
'adUnitId': adUnitId,
};
if (requestConfig != null) {
params.addAll(requestConfig.toMap());
}
final result = await _channel.invokeMethod<bool>(
'preloadInterstitialAd',
params,
);
return result ?? false;
} catch (e) {
debugPrint('Error loading interstitial ad: $e');
return false;
}
}