setOption method Null safety

  1. @override
Future<ResultCode> setOption(
  1. dynamic option,
  2. OptionType type
)

Set option object to PANO SDK.

Parameter option The Option object.

Parameter type PanoOptionType enum type.

Returns

设置选项对象给PANO SDK。

Parameter option 选项对象。

Parameter type PanoOptionType 枚举类型。

Returns

Implementation

@override
Future<ResultCode> setOption(option, OptionType type) {
  var params = <String, dynamic>{};
  params['type'] = OptionTypeConverter(type).value();
  var isValid = true;
  switch (type) {
    case OptionType.FaceBeautify:
      if (option is FaceBeautifyOption) {
        params['option'] = option.toJson();
      } else {
        isValid = false;
      }
      break;
    case OptionType.UploadLogs:
      if (option is bool) {
        params['option'] = option;
      } else {
        isValid = false;
      }
      break;
    case OptionType.UploadAudioDump:
      if (option is bool) {
        params['option'] = option;
      } else {
        isValid = false;
      }
      break;
    case OptionType.AudioEqualizationMode:
      if (option is AudioEqualizationMode) {
        params['option'] = AudioEqualizationModeConverter(option).value();
      } else {
        isValid = false;
      }
      break;
    case OptionType.AudioReverbMode:
      if (option is AudioReverbMode) {
        params['option'] = AudioReverbModeConverter(option).value();
      } else {
        isValid = false;
      }
      break;
    case OptionType.VideoFrameRate:
      if (option is VideoFrameRateType) {
        params['option'] = VideoFrameRateTypeConverter(option).value();
      } else {
        isValid = false;
      }
      break;
    case OptionType.AudioEarMonitoring:
      if (option is bool) {
        params['option'] = option;
      } else {
        isValid = false;
      }
      break;
    case OptionType.BuiltinTransform:
      isValid = false;
      break;
    case OptionType.UploadLogsAtFailure:
      if (option is bool) {
        params['option'] = option;
      } else {
        isValid = false;
      }
      break;
    case OptionType.CpuAdaption:
      if (option is bool) {
        params['option'] = option;
      } else {
        isValid = false;
      }
      break;
    case OptionType.AudioProfile:
      if (option is RtcAudioProfile) {
        params['option'] = option.toJson();
      } else {
        isValid = false;
      }
      break;
    case OptionType.QuadTransform:
      if (option is QuadTransformOption) {
        params['option'] = option.toJson();
      } else {
        isValid = false;
      }
      break;
    case OptionType.ScreenOptimization:
      if (option is bool) {
        params['option'] = option;
      } else {
        isValid = false;
      }
      break;
    default:
      isValid = false;
  }

  if (!isValid) return Future.value(ResultCode.InvalidArgs);

  return _invokeCodeMethod('setOption', params);
}