setup static method

void setup(
  1. CallbackHandlerApi? api, {
  2. BinaryMessenger? binaryMessenger,
})

Implementation

static void setup(CallbackHandlerApi? api,
    {BinaryMessenger? binaryMessenger}) {
  {
    final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
        'dev.flutter.pigeon.CallbackHandlerApi.handleCallback', codec,
        binaryMessenger: binaryMessenger);
    if (api == null) {
      channel.setMessageHandler(null);
    } else {
      channel.setMessageHandler((Object? message) async {
        assert(message != null,
            'Argument for dev.flutter.pigeon.CallbackHandlerApi.handleCallback was null.');
        final List<Object?> args = (message as List<Object?>?)!;
        final String? arg_callbackId = (args[0] as String?);
        assert(arg_callbackId != null,
            'Argument for dev.flutter.pigeon.CallbackHandlerApi.handleCallback was null, expected non-null String.');
        final String? arg_callbackName = (args[1] as String?);
        assert(arg_callbackName != null,
            'Argument for dev.flutter.pigeon.CallbackHandlerApi.handleCallback was null, expected non-null String.');
        final List<Object?>? arg_args = (args[2] as List<Object?>?);
        assert(arg_args != null,
            'Argument for dev.flutter.pigeon.CallbackHandlerApi.handleCallback was null, expected non-null List<Object?>.');
        api.handleCallback(arg_callbackId!, arg_callbackName!, arg_args!);
        return;
      });
    }
  }
}