publish method

void publish(
  1. String topic,
  2. String message, {
  3. bool retain = false,
})

Implementation

void publish(String topic, String message, {bool retain = false}) {
  final builder = MqttClientPayloadBuilder();
  builder.addUTF8String(message);
  if (builder.payload == null) return;
  mqttClient?.publishMessage(topic, MqttQos.atLeastOnce, builder.payload!,
      retain: retain);

  log('Published to topic: $topic, message: $message');
}