setUp static method

void setUp(
  1. AppleSpeechCallbackApi? api, {
  2. BinaryMessenger? binaryMessenger,
  3. String messageChannelSuffix = '',
})

Implementation

static void setUp(
  AppleSpeechCallbackApi? api, {
  BinaryMessenger? binaryMessenger,
  String messageChannelSuffix = '',
}) {
  messageChannelSuffix = messageChannelSuffix.isNotEmpty
      ? '.$messageChannelSuffix'
      : '';
  {
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.apple_speech.AppleSpeechCallbackApi.onAnalyzerResult$messageChannelSuffix',
      pigeonChannelCodec,
      binaryMessenger: binaryMessenger,
    );
    if (api == null) {
      pigeonVar_channel.setMessageHandler(null);
    } else {
      pigeonVar_channel.setMessageHandler((Object? message) async {
        final List<Object?> args = message! as List<Object?>;
        final AnalyzerResultMessage arg_result =
            args[0]! as AnalyzerResultMessage;
        try {
          api.onAnalyzerResult(arg_result);
          return wrapResponse(empty: true);
        } on PlatformException catch (e) {
          return wrapResponse(error: e);
        } catch (e) {
          return wrapResponse(
            error: PlatformException(code: 'error', message: e.toString()),
          );
        }
      });
    }
  }
  {
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.apple_speech.AppleSpeechCallbackApi.onRecognitionResult$messageChannelSuffix',
      pigeonChannelCodec,
      binaryMessenger: binaryMessenger,
    );
    if (api == null) {
      pigeonVar_channel.setMessageHandler(null);
    } else {
      pigeonVar_channel.setMessageHandler((Object? message) async {
        final List<Object?> args = message! as List<Object?>;
        final RecognitionResultMessage arg_result =
            args[0]! as RecognitionResultMessage;
        try {
          api.onRecognitionResult(arg_result);
          return wrapResponse(empty: true);
        } on PlatformException catch (e) {
          return wrapResponse(error: e);
        } catch (e) {
          return wrapResponse(
            error: PlatformException(code: 'error', message: e.toString()),
          );
        }
      });
    }
  }
  {
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.apple_speech.AppleSpeechCallbackApi.onInstallProgress$messageChannelSuffix',
      pigeonChannelCodec,
      binaryMessenger: binaryMessenger,
    );
    if (api == null) {
      pigeonVar_channel.setMessageHandler(null);
    } else {
      pigeonVar_channel.setMessageHandler((Object? message) async {
        final List<Object?> args = message! as List<Object?>;
        final int arg_requestId = args[0]! as int;
        final double arg_fractionCompleted = args[1]! as double;
        try {
          api.onInstallProgress(arg_requestId, arg_fractionCompleted);
          return wrapResponse(empty: true);
        } on PlatformException catch (e) {
          return wrapResponse(error: e);
        } catch (e) {
          return wrapResponse(
            error: PlatformException(code: 'error', message: e.toString()),
          );
        }
      });
    }
  }
  {
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.apple_speech.AppleSpeechCallbackApi.onRequestDone$messageChannelSuffix',
      pigeonChannelCodec,
      binaryMessenger: binaryMessenger,
    );
    if (api == null) {
      pigeonVar_channel.setMessageHandler(null);
    } else {
      pigeonVar_channel.setMessageHandler((Object? message) async {
        final List<Object?> args = message! as List<Object?>;
        final int arg_requestId = args[0]! as int;
        final double? arg_lastSampleTime = args[1] as double?;
        try {
          api.onRequestDone(arg_requestId, arg_lastSampleTime);
          return wrapResponse(empty: true);
        } on PlatformException catch (e) {
          return wrapResponse(error: e);
        } catch (e) {
          return wrapResponse(
            error: PlatformException(code: 'error', message: e.toString()),
          );
        }
      });
    }
  }
  {
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.apple_speech.AppleSpeechCallbackApi.onRequestError$messageChannelSuffix',
      pigeonChannelCodec,
      binaryMessenger: binaryMessenger,
    );
    if (api == null) {
      pigeonVar_channel.setMessageHandler(null);
    } else {
      pigeonVar_channel.setMessageHandler((Object? message) async {
        final List<Object?> args = message! as List<Object?>;
        final int arg_requestId = args[0]! as int;
        final ErrorMessage arg_error = args[1]! as ErrorMessage;
        try {
          api.onRequestError(arg_requestId, arg_error);
          return wrapResponse(empty: true);
        } on PlatformException catch (e) {
          return wrapResponse(error: e);
        } catch (e) {
          return wrapResponse(
            error: PlatformException(code: 'error', message: e.toString()),
          );
        }
      });
    }
  }
}