-
-
Notifications
You must be signed in to change notification settings - Fork 153
Banner Ads
Elias edited this page Oct 27, 2020
·
4 revisions
Make sure you have initialize the plugin first. You can learn how to do this in the Installation Wiki Page
This plugin uses Native Platform Views to show Admob banner ads thus, same as any other widget, there's no limitations on where to place your banners.
AdmobBanner(
adUnitId: AdmobBanner.testAdUnitId,
adSize: AdmobBannerSize.BANNER,
)
The plugin provides all banner sizes supported by Admob, and will wrap the banner with a correctly sized Container
so you don't worry about your ad displaying incorrectly:
-
AdmobBannerSize.BANNER
: 320x50 -
AdmobBannerSize.LARGE_BANNER
: 320x100 -
AdmobBannerSize.MEDIUM_RECTANGLE
: 300x250 -
AdmobBannerSize.FULL_BANNER
: 468x60 -
AdmobBannerSize.LEADERBOARD
: 728x90 -
AdmobBannerSize.SMART_BANNER
: Wrap in a container with a size of your choice -
AdmobBannerSize.ADAPTIVE_BANNER
: Adaptive banners are the next generation of responsive ads . https://developers.google.com/admob/android/banner/adaptive
You can attach a listener to your ads in order to customize their behavior like this:
AdmobBanner(
adUnitId: AdmobBanner.testAdUnitId,
adSize: AdmobBannerSize.BANNER,
listener: (AdmobAdEvent event, Map<String, dynamic> args) {
switch (event) {
case AdmobAdEvent.loaded:
print('Admob banner loaded!');
break;
case AdmobAdEvent.opened:
print('Admob banner opened!');
break;
case AdmobAdEvent.closed:
print('Admob banner closed!');
break;
case AdmobAdEvent.failedToLoad:
print('Admob banner failed to load. Error code: ${args['errorCode']}');
break;
}
}
)