.
This commit is contained in:
parent
fd6266b30b
commit
b491112b4c
2 changed files with 8 additions and 2 deletions
|
|
@ -13,6 +13,7 @@ class _MihBannerAdState extends State<MihBannerAd> {
|
|||
BannerAd? _bannerAd;
|
||||
bool _isBannerAdLoaded = false;
|
||||
final adUnitId = AppEnviroment.bannerAdUnitId;
|
||||
String errorMessage = '';
|
||||
|
||||
void _loadBannerAd() {
|
||||
_bannerAd = BannerAd(
|
||||
|
|
@ -28,6 +29,9 @@ class _MihBannerAdState extends State<MihBannerAd> {
|
|||
},
|
||||
onAdFailedToLoad: (ad, err) {
|
||||
debugPrint('BannerAd failed to load: $err');
|
||||
setState(() {
|
||||
errorMessage = 'Failed to load ad: ${err.message}';
|
||||
});
|
||||
ad.dispose(); // Dispose the ad to free resources
|
||||
},
|
||||
onAdOpened: (Ad ad) => debugPrint('$ad opened.'),
|
||||
|
|
@ -60,7 +64,9 @@ class _MihBannerAdState extends State<MihBannerAd> {
|
|||
width: _bannerAd!.size.width.toDouble(),
|
||||
height: _bannerAd!.size.height.toDouble(),
|
||||
child: AdWidget(ad: _bannerAd!))
|
||||
: SizedBox(),
|
||||
: SizedBox(
|
||||
child: Text(errorMessage),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
name: mzansi_innovation_hub
|
||||
description: ""
|
||||
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:
|
||||
sdk: '>=3.5.3 <4.0.0'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue