loadBanner method
Implementation
@protected
Future<void> loadBanner() async {
final bannerState = ref.read(_bannerStateProvider);
if (!bannerState.isBannerAvailable) {
debugPrint('AD not available');
return;
}
if (bannerState.bannerAd != null) {
await disposeBanner();
}
final bannerId = _chobiAdMob?.getAdId();
//debugPrint('banner id = $bannerId');
if (bannerId == null) {
debugPrint('banner id is null');
return;
}
final cWidth = MediaQuery.of(context).size.width.truncate();
final adSize = await AdSize.getCurrentOrientationAnchoredAdaptiveBannerAdSize(cWidth);
if (adSize == null) {
debugPrint('adSize is null');
return;
}
final ad = BannerAd(
size: adSize,
adUnitId: bannerId,
listener: generateBannerListener(),
request: const AdRequest(),
);
//_updateBannerState(ref, bannerAdGetter: () => ad);
await ad.load();
}