setUp static method

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

Implementation

static void setUp(
  AppleTranslationCallbackApi? api, {
  BinaryMessenger? binaryMessenger,
  String messageChannelSuffix = '',
}) {
  messageChannelSuffix = messageChannelSuffix.isNotEmpty
      ? '.$messageChannelSuffix'
      : '';
  {
    final pigeonVar_channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.apple_translation.AppleTranslationCallbackApi.onBatchResponse$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 TranslationResponseMessage arg_response =
            args[1]! as TranslationResponseMessage;
        try {
          api.onBatchResponse(arg_requestId, arg_response);
          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_translation.AppleTranslationCallbackApi.onBatchDone$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;
        try {
          api.onBatchDone(arg_requestId);
          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_translation.AppleTranslationCallbackApi.onBatchError$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.onBatchError(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()),
          );
        }
      });
    }
  }
}