setUp static method

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

Implementation

static void setUp(
  InAppPurchase2CallbackAPI? api, {
  BinaryMessenger? binaryMessenger,
  String messageChannelSuffix = '',
}) {
  messageChannelSuffix = messageChannelSuffix.isNotEmpty
      ? '.$messageChannelSuffix'
      : '';
  {
    final BasicMessageChannel<Object?>
    pigeonVar_channel = BasicMessageChannel<Object?>(
      'dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated$messageChannelSuffix',
      pigeonChannelCodec,
      binaryMessenger: binaryMessenger,
    );
    if (api == null) {
      pigeonVar_channel.setMessageHandler(null);
    } else {
      pigeonVar_channel.setMessageHandler((Object? message) async {
        assert(
          message != null,
          'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null.',
        );
        final List<Object?> args = (message as List<Object?>?)!;
        final List<SK2TransactionMessage>? arg_newTransactions =
            (args[0] as List<Object?>?)?.cast<SK2TransactionMessage>();
        assert(
          arg_newTransactions != null,
          'Argument for dev.flutter.pigeon.in_app_purchase_storekit.InAppPurchase2CallbackAPI.onTransactionsUpdated was null, expected non-null List<SK2TransactionMessage>.',
        );
        try {
          api.onTransactionsUpdated(arg_newTransactions!);
          return wrapResponse(empty: true);
        } on PlatformException catch (e) {
          return wrapResponse(error: e);
        } catch (e) {
          return wrapResponse(
            error: PlatformException(code: 'error', message: e.toString()),
          );
        }
      });
    }
  }
}