load method
Loads an interstitial ad for the given position.
position: The unique identifier for the ad placement (e.g., "interstitial_1").pageType: (Optional) The type of page or context for the ad (e.g., "home", "detail").
If an ad is already loading, this method does nothing.
Sets isLoaded to true if loading succeeds, otherwise false.
Throws a PlatformException if loading fails.
Implementation
Future<void> load(String position, {String? pageType}) async {
if (_isLoading) {
print('Interstitial ad is already loading');
return;
}
try {
_isLoading = true;
print('Loading interstitial ad...');
await HighfivveAdManager.instance
.loadInterstitialAd(position, pageType: pageType);
_isLoaded = true;
print('Interstitial ad loaded successfully');
} on PlatformException catch (e) {
print('Failed to load interstitial ad: ${e.message}');
_isLoaded = false;
} finally {
_isLoading = false;
}
}