0

当我在 pubspec.yaml 添加 google_mobile_ads: ^0.13.4 依赖项时出现上述错误我没有解决方案但有人有解决方案所以请告诉我...... ..................................................... ..................................................... ..................................................... ......................

main.dart 

void createBottomBannerAd(){
  _bottamBannerAd=BannerAd(
      size: AdSize.banner,
    request:AdRequest(),
    adUnitId: AdHelper.bannerAdUnitId,
      listener: BannerAdListener(
        onAdLoaded: (_){
          setState(() {
            _isBottamBannerAdloaded=true;
          });
        },
      onAdFailedToLoad: (ad,error){
          ad.dispose();
      }
        ),
  );
  _bottamBannerAd.load();
}
void _creatInlineBannerAd(){
  _inlineBannerAd=BannerAd(
      size: AdSize.mediumRectangle,
      adUnitId: AdHelper.bannerAdUnitId,
      listener: BannerAdListener(onAdLoaded: (_){
        setState(() {
          _isInlineBannerAdloaded=true;
        });
      },
      onAdFailedToLoad:(ad,error){
        ad.dispose();
      }
      ),
      request: AdRequest(),
  );
  _inlineBannerAd.load();
}
void _createintrestialBannerAd(){
  InterstitialAd.load(adUnitId: AdHelper.interstitialAdUnitId,
      request: AdRequest(), adLoadCallback: InterstitialAdLoadCallback(
          onAdLoaded: (InterstitialAd ad)
          {
            _interstitialAd= ad;
          _interstitialLoadAttempts=0;
          },
          onAdFailedToLoad:(LoadAdError error) {
            _interstitialLoadAttempts+=1;
            _interstitialAd= null;
            if(_interstitialLoadAttempts >= maxFailedLoadAttempt){
              _createintrestialBannerAd();
            }
          }));
}
void _showintrestialAd(){
  if(_interstitialAd != null){
    _interstitialAd.fullScreenContentCallback=FullScreenContentCallback
      (onAdWillDismissFullScreenContent: (InterstitialAd ad){
      ad.dispose();
      _createintrestialBannerAd();
    },
    onAdFailedToShowFullScreenContent: (InterstitialAd ad,AdError error){
ad.dispose();
_createintrestialBannerAd();
    });
    _interstitialAd.show();
  }
}
4

0 回答 0