AdropBannerController.withId constructor
- int id, {
- required AdropBanner banner,
- void onAdReceived(
- AdropBanner banner
- void onAdClicked(
- AdropBanner banner
- void onAdFailedToReceive(
- AdropBanner banner,
- AdropErrorCode errorCode
Banner controller class responsible for requesting banner ads.
id required view id
onAdReceived optional invoked when the banner receives an ad.
onAdClicked optional invoked when the AdropBanner is clicked.
onAdFailedToReceive optional invoked when the banner fails to receive an ad.
Implementation
AdropBannerController.withId(
int id, {
required AdropBanner banner,
this.onAdReceived,
this.onAdClicked,
this.onAdFailedToReceive,
}) : _banner = banner,
_channel =
MethodChannel(AdropChannel.bannerEventListenerChannelOf(id)) {
_channel.setMethodCallHandler((call) async {
switch (call.method) {
case AdropMethod.didReceiveAd:
onAdReceived?.call(_banner);
break;
case AdropMethod.didClickAd:
onAdClicked?.call(_banner);
break;
case AdropMethod.didFailToReceiveAd:
onAdFailedToReceive?.call(
_banner, AdropErrorCode.getByCode(call.arguments));
break;
}
});
}