小编Bri*_*Tum的帖子

如何在flutter中显示多个谷歌原生广告

我试图在 a 中动态调用广告listview,但抛出此错误:

If you placed this AdWidget in a list, make sure you create a new instance in the builder function with a unique ad object.
Make sure you are not using the same ad object in more than one AdWidget. 
Run Code Online (Sandbox Code Playgroud)

这是代码

导入包google_mobile_ads

import 'package:google_mobile_ads/google_mobile_ads.dart';
Run Code Online (Sandbox Code Playgroud)

然后实例化包

NativeAd _nativeAd;

final Completer<NativeAd> nativeAdCompleter = Completer<NativeAd>();
Run Code Online (Sandbox Code Playgroud)

我的功能是加载广告

loadAd(){
    _nativeAd = NativeAd(
      adUnitId: "ca-app-pub-3940256099942544/1044960115",
      request: AdRequest(),
      factoryId: 'adFactoryExample',
      listener: AdListener(
        onAdLoaded: (Ad ad) {
          print('$NativeAd loaded.');
          nativeAdCompleter.complete(ad as NativeAd); …
Run Code Online (Sandbox Code Playgroud)

admob flutter google-mobile-ads

5
推荐指数
1
解决办法
1956
查看次数

标签 统计

admob ×1

flutter ×1

google-mobile-ads ×1