InstreamAdLoader constructor
InstreamAdLoader({})
Implementation
InstreamAdLoader({
required this.adId,
required this.totalDuration,
this.maxCount,
this.onAdLoaded,
this.onAdFailed,
}) {
Ads.instance.channelInstream.invokeMethod(
'initInstreamLoader',
<String, dynamic>{
'id': hashCode,
'adId': adId,
'totalDuration': totalDuration.inSeconds,
'maxCount': maxCount,
},
);
_channel = MethodChannel('$_INSTREAM_METHOD_CHANNEL/LOADER/$hashCode');
_channel.setMethodCallHandler((MethodCall call) async {
switch (call.method) {
case 'onAdLoaded':
List<int> ads = List<int>.from(call.arguments['ads']);
List<InstreamAd> instreamAds = <InstreamAd>[];
for (int adId in ads) {
instreamAds.add(InstreamAd(id: adId));
}
onAdLoaded?.call(instreamAds);
break;
case 'onAdFailed':
onAdFailed?.call(call.arguments['error_code']);
break;
default:
throw UnimplementedError;
}
return;
});
}