sendCommand method Null safety

String sendCommand(
  1. Map<String, dynamic> payload,
  2. [Map<String, dynamic>? args]
)

This is the lower level send that transmits the command supplied on the websocket, It requires a payload, the command as a Map that will be json encoded in the format required by OBS, and the args. Both are combined into a single Map that is json encoded and transmitted over the websocket.

Implementation

String sendCommand(Map<String, dynamic> payload,
    [Map<String, dynamic>? args]) {
  message_id++;

  payload['message-id'] = message_id.toString();

  if (args != null) {
    payload.addAll(args);
  }

  final requestPayload = jsonEncode(payload);

  channel.sink.add(requestPayload);

  return message_id.toString();
}