_bannerAd = BannerAd(
size: AdSize.banner,
............
这完全运作良好,但是
_bannerAd = BannerAd(
size: AdSize(width:320, height: 50),
.............
它根本不适用于下面
error failed code : 3
我的包裹是
google_mobile_ads: 0.11.0+4
最后小部件代码如下
Container(
height: _bannerAd.size.height.toDouble(),
width: _bannerAd.size.width.toDouble(),
child: AdWidget(ad: _bannerAd))
你的问题不太具体。但是根据您的错误代码,这似乎与您的 AdSize 无关。 Google Play 参考资料显示广告请求成功,但由于广告库存不足而没有返回任何广告。
我正在使用 google_mobile_ads:^5.1.0,通过此软件包版本,我可以显示具有自定义尺寸的 BannerAd。
下面是如何使用它的示例
BannerAd? bannerAd;
bannerAd = BannerAd(
size: AdSize(width: 320, height: 50),
adUnitId: bannerAdUnitId,
request: const AdRequest(),
listener: BannerAdListener(
// Called when an ad is successfully received.
onAdLoaded: (ad) {
print("adLoaded ${ad.adUnitId}");
},
// Called when an ad request failed.
onAdFailedToLoad: (ad, err) {
print("onAdFailedToLoad$err");
ad.dispose();
},
// Called when an ad opens an overlay that covers the screen.
onAdOpened: (Ad ad) {
print("onAdOpened$ad");
},
// Called when an ad removes an overlay that covers the screen.
onAdClosed: (Ad ad) {
print("onAdClosed$ad");
},
// Called when an impression occurs on the ad.
onAdImpression: (Ad ad) {
print("onAdImpression$ad");
},
),
);
bannerAd?.load();