On Dart I am facing challenges

Hi,

I have used the code snipped provided on the portal and this is throwing lot of build errors like
client.publishMessage(
‘Dart/Mqtt_client/testtopic’, MqttQos.exactlyOnce, builder.payload);
where builder.payload is of Uint8Buffer and then also throwing argument type mismatch error.

Hi pankajmotiyar,

it is great that you are trying HiveMQ. Could you please be more specific: which snippet of code is this about and where is it on the portal? Did you find a way to work around the issue?

Thanks,
Dasha from HivemMQ

while trying to execute this code
https://console.hivemq.cloud/clients/mqtt-dart?uuid=54063f80aeed4f82bdbdffa828dc63a5

the codeblock
void _publishMessage(String message) {
final MqttClientPayloadBuilder builder = MqttClientPayloadBuilder();
builder.addString(message);

print(
    'Publishing message "$message" to topic ${'Dart/Mqtt_client/testtopic'}');
client.publishMessage(
    'Dart/Mqtt_client/testtopic', MqttQos.exactlyOnce, **builder.payload**);

}

is throwing error The argument type ‘Uint8Buffer?’ can’t be assigned to the parameter type ‘Uint8Buffer’ in builder.payload

also in the method _connectClient()
// when connected, print a confirmation, else print an error
if (client.connectionStatus.state == MqttConnectionState.connected) {
connectionState = MqttCurrentConnectionState.CONNECTED;
print(‘client connected’);
} else {
print(
‘ERROR client connection failed - disconnecting, status is ${client.connectionStatus}’);
connectionState = MqttCurrentConnectionState.ERROR_WHEN_CONNECTING;
client.disconnect();
}

client.connectionStatus.state The property ‘state’ can’t be uncondionally accessed because the receiver can;t be null.

I am new to dart and not able to resolve these errors.

Hi pankajmotiyar,

I have just tested this myself and everything worked. I have cloned the Dart project from the GitHub repo, then I have installed Dart and followed the instructions in the mqtt.dart-client-example/README.md file.
My client has successfully connected to my HiveMQ cloud cluster with username and password. It has published the message from the Dart project. Also, when I publish a message from another, MQTT CLI, client, the Dart client receives it as well.
Perhaps you could repeat the instructions step by step and see if there is anything missing.

Kind regards,
Dasha from HiveMQ Team