This commit is contained in:
2025-06-30 18:16:46 +02:00
parent fd6266b30b
commit b491112b4c
2 changed files with 8 additions and 2 deletions

View File

@@ -13,6 +13,7 @@ class _MihBannerAdState extends State<MihBannerAd> {
BannerAd? _bannerAd; BannerAd? _bannerAd;
bool _isBannerAdLoaded = false; bool _isBannerAdLoaded = false;
final adUnitId = AppEnviroment.bannerAdUnitId; final adUnitId = AppEnviroment.bannerAdUnitId;
String errorMessage = '';
void _loadBannerAd() { void _loadBannerAd() {
_bannerAd = BannerAd( _bannerAd = BannerAd(
@@ -28,6 +29,9 @@ class _MihBannerAdState extends State<MihBannerAd> {
}, },
onAdFailedToLoad: (ad, err) { onAdFailedToLoad: (ad, err) {
debugPrint('BannerAd failed to load: $err'); debugPrint('BannerAd failed to load: $err');
setState(() {
errorMessage = 'Failed to load ad: ${err.message}';
});
ad.dispose(); // Dispose the ad to free resources ad.dispose(); // Dispose the ad to free resources
}, },
onAdOpened: (Ad ad) => debugPrint('$ad opened.'), onAdOpened: (Ad ad) => debugPrint('$ad opened.'),
@@ -60,7 +64,9 @@ class _MihBannerAdState extends State<MihBannerAd> {
width: _bannerAd!.size.width.toDouble(), width: _bannerAd!.size.width.toDouble(),
height: _bannerAd!.size.height.toDouble(), height: _bannerAd!.size.height.toDouble(),
child: AdWidget(ad: _bannerAd!)) child: AdWidget(ad: _bannerAd!))
: SizedBox(), : SizedBox(
child: Text(errorMessage),
),
], ],
); );
} }

View File

@@ -1,7 +1,7 @@
name: mzansi_innovation_hub name: mzansi_innovation_hub
description: "" description: ""
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.1.12+83 version: 1.1.12+84
environment: environment:
sdk: '>=3.5.3 <4.0.0' sdk: '>=3.5.3 <4.0.0'