callbackHandler method

Future callbackHandler(
  1. MethodCall call
)

Implementation

Future<dynamic> callbackHandler(MethodCall call) async {
  var methodName = call.method;
  var requestId = call.arguments['request_who'];

  if ((requestId as String?)?.isEmpty == true) {
    return Future.value(null);
  }
  switch (methodName) {
    case 'onAdLoaded':
      _adLoadListenerMap[requestId]?.onAdLoaded?.call();
      break;
    case 'onAdLoadError':
      try {
        _adLoadListenerMap[requestId]?.onAdLoadError?.call(SanAdError.fromMap(call.arguments));
      } on Exception catch (e) {
        log(e.toString());
      }
      break;
    case 'onAdImpressionError':
      _adActionListenerMap[requestId]?.onAdImpressionError?.call(SanAdError.fromMap(call.arguments));
      break;
    case 'onAdImpression':
      _adActionListenerMap[requestId]?.onAdImpression?.call();
      break;
    case 'onAdClicked':
      _adActionListenerMap[requestId]?.onAdClicked?.call();
      break;
    case 'onAdCompleted':
      _adActionListenerMap[requestId]?.onAdCompleted?.call();
      break;
    case 'onAdClosed':
      _adActionListenerMap[requestId]?.onAdClosed?.call(call.arguments['hasRewarded']);
      break;
  }
}