示例代码:
import 'package:firebase_admob/firebase_admob.dart';
MobileAdTargetingInfo targetingInfo = MobileAdTargetingInfo(
keywords:
BannerAd myBanner = BannerAd( adUnitId: BannerAd.testAdUnitId, size: AdSize.banner, targetingInfo: targetingInfo, listener: (MobileAdEvent event) { print("BannerAd event is $event"); }, );
// use BannerAd as a child widget Container( child: AdWidget(ad: myBanner), width: myBanner.size.width.toDouble(), height: myBanner.size.height.toDouble(), )
注意:上面的代码示例中使用的是测试广告单元ID。在您的应用程序中,请使用您在Admob网站上创建的生产广告单元ID。