loadAppOpenAd static method
Loads an AppOpenAd with the given id.
id is the ad unit ID.
onAdClosed is called when the ad is closed or fails to show.
Implementation
static void loadAppOpenAd(String id, {required void Function() onAdClosed}) {
AppOpenAd.load(
adUnitId: id,
request: const AdRequest(),
adLoadCallback: AppOpenAdLoadCallback(
onAdLoaded: (ad) {
ad
..fullScreenContentCallback = FullScreenContentCallback(
onAdDismissedFullScreenContent: (ad) {
ad.dispose();
onAdClosed();
},
onAdFailedToShowFullScreenContent: (ad, error) {
ad.dispose();
onAdClosed();
},
)
..show();
},
onAdFailedToLoad: (error) {
LoggerUtil.e('AppOpenAd failed to load: $error');
onAdClosed();
},
),
);
}