loadBannerAd method
Future<StartAppBannerAd>
loadBannerAd(
- StartAppBannerType type, {
- StartAppAdPreferences prefs = const StartAppAdPreferences(),
- VoidCallback? onAdImpression,
- VoidCallback? onAdClicked,
Loads banner ad, creates an underlying native platform view.
Once loaded the banner must be shown immediately with StartAppBanner. Banner will be refreshed automatically.
Implementation
Future<StartAppBannerAd> loadBannerAd(
StartAppBannerType type, {
StartAppAdPreferences prefs = const StartAppAdPreferences(),
VoidCallback? onAdImpression,
VoidCallback? onAdClicked,
}) {
return _channel.invokeMethod('loadBannerAd', prefs._toMap({'type': type.index})).then((value) {
if (value is Map) {
dynamic id = value['id'];
if (id is int && id > 0) {
if (onAdImpression != null) {
onAdImpressionCallbacks[id] = onAdImpression;
}
if (onAdClicked != null) {
onAdClickedCallbacks[id] = onAdClicked;
}
return StartAppBannerAd._(id, value.cast());
}
}
throw StartAppException(message: value);
});
}