loadAd method
void
loadAd({
- dynamic isFromStart = false,
Load an AppOpenAd.
Implementation
void loadAd({isFromStart = false}) async {
// Only load an ad if the Mobile Ads SDK has gathered consent aligned with
// the app's configured messages.
AppOpenAd.load(
adUnitId: appOpenUnitId,
request: const AdRequest(),
adLoadCallback: AppOpenAdLoadCallback(
onAdLoaded: (ad) {
if (kDebugMode) {
print('$ad loaded');
}
_appOpenLoadTime = DateTime.now();
_appOpenAd = ad;
if (isFromStart) {
showAdIfAvailable();
}
this.isFromStart = false;
},
onAdFailedToLoad: (error) {
if (kDebugMode) {
print('AppOpenAd failed to load: $error');
}
},
),
);
}