BigoAd<T extends BigoAdInteractionListener> constructor

BigoAd<T extends BigoAdInteractionListener>({
  1. required BigoAdMessageReader reader,
  2. required StandardMessageCodec codec,
})

Implementation

BigoAd(
    {required BigoAdMessageReader reader,
    required StandardMessageCodec codec})
    : adId = reader.readMessage(),
      adBid = reader.readMessage(),
      creativeId = reader.readMessage() {
  _channel = MethodChannel(
    'plugins.flutter.bigo/bigo_ads/ad_instance_$adId',
    StandardMethodCodec(codec),
  );
  _channel.setMethodCallHandler((MethodCall call) async {
    assert(call.arguments['adId'] == adId);
    switch (call.method) {
      case 'onAdError':
        _onAdError(call.arguments['adError']);
        break;
      case 'onAdImpression':
        _onAdImpression();
        break;
      case 'onAdClicked':
        _onAdClicked();
        break;
      case 'onAdOpened':
        _onAdOpened();
        break;
      case 'onAdClosed':
        _onAdClosed();
        break;
      default:
        _onMethodCall(call.method, call.arguments);
        break;
    }
  });
  adBid?._bigoAd = this;
}