Banner Ad
1. Basic Requirements
Add ADX Flutter SDK to your project.
Use the ADX Ad Unit ID issued for Banner Ad.
Before requesting an ad, SDK initialization must be done first.
SDK initialization should be called only once when the app launches and ad requests should be made after SDK initialization is complete.
2. Implementation
If the app is distributed on both Android and iOS, enter the Ad Unit ID issued for each platform.
Register the required callbacks.
Call
loadBannerAd()
to load the ad.
String adUnitId = Platform.isAndroid ? "<ANDROID_ADX_BANNER_AD_UNIT_ID>" : "<IOS_ADX_BANNER_AD_UNIT_ID>";
AdxSdk.setBannerListener(BannerListener(
onAdLoaded: (){
},
onAdError: (int errorCode) {
},
onAdClicked: (){
}));
AdxSdk.setBannerPosition(adUnitId, AdxCommon.positionBottomCenter);
AdxSdk.loadBannerAd(adUnitId, AdxCommon.size_320x50);
Call
destroyBannerAd()
when the ad object is being disposed.
@override
void dispose() {
super.dispose();
AdxSdk.destroyBannerAd(adUnitId);
}
The supported sizes and positions for banner ads are as follows.
// -------- Banner Ad Size --------
static const String size_320x50 = "320x50";
static const String size_320x100 = "320x100";
static const String size_300x250 = "300x250";
static const String size_728x90 = "728x90";
// -------- Banner Ad Position --------
static const String positionTopCenter = "top_center";
static const String positionTopLeft = "top_left";
static const String positionTopRight = "top_right";
static const String positionCenter = "center";
static const String positionCenterLeft = "center_left";
static const String positionCenterRight = "center_right";
static const String positionBottomCenter = "bottom_center";
static const String positionBottomLeft = "bottom_left";
static const String positionBottomRight = "bottom_right";
3. Callback
You can receive specific events. Implement as needed.
class BannerListener {
void Function() onAdLoaded;
void Function(int errorCode) onAdError;
void Function() onAdClicked;
BannerListener({
required this.onAdLoaded,
required this.onAdError,
required this.onAdClicked
});
}
Last updated
Was this helpful?