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