【问题标题】:The method 'AdListener' isn't defined for the type 'NavigationCounter'方法 \'AdListener\' 没有为类型 \'NavigationCounter\' 定义
【发布时间】:2023-01-05 16:05:25
【问题描述】:

更新 google_mobile_ads 13.0 后出现错误。未为类型“NavigationCounter”定义方法“AdListener”。

    listener = AdListener(
  // Called when an ad is successfully received.
  onAdLoaded: (Ad ad) {
    //appLockService.disable();
    googleLoad = true;
  },
  // Called when an ad request failed.
  onAdFailedToLoad: (Ad ad, LoadAdError error) {
    print('Ad failed to load: $error');
    //googleLoad = false;
    myInterstitial.dispose();
    //appLockService.unlockScreen();
    //myInterstitial.load();
  },
  // Called when an ad opens an overlay that covers the screen.
  onAdOpened: (Ad ad) => print('Ad opened.'),
  // Called when an ad removes an overlay that covers the screen.
  onAdClosed: (Ad ad) async {
    await isPurchasedFunc();
    print('Ad closed.');
    _adCount++;
    googleLoad = false;
    myInterstitial.dispose();

    if (_adCount == 1) {
      print("isPurchased: $isPurchased & openCount:$openCount");
      if ((isPurchased == null || isPurchased == false) &&
          (openCount == 2 || openCount == 4)) {
        inAppDialog(context);
      }
    }
 
  },
  // Called when an ad is in the process of leaving the application.
  onApplicationExit: (Ad ad) => print('Left application.'),
);

卡在听众 =广告监听器()

【问题讨论】:

    标签: flutter flutter-layout admob interstitial


    【解决方案1】:

    替换为BannerAdListener();

    BannerAd(
       size: AdSize.mediumRectangle,
       adUnitId: AdHelper.bannerAdUnitId,
       request: AdRequest(),
       listener: BannerAdListener(
         onAdLoaded: (_) {
           setState(() {
             _isInlineBannerAdLoaded = true;
           });
         },
         onAdFailedToLoad: (ad, error) {
           ad.dispose();
         },
       ),
     )
    

    【讨论】:

      猜你喜欢
      • 2021-09-02
      • 2022-11-21
      • 2021-10-19
      • 2020-12-14
      • 2021-07-19
      • 2021-09-01
      • 2021-09-17
      • 2021-06-11
      • 2021-06-28
      相关资源
      最近更新 更多