Skip to content

Instantly share code, notes, and snippets.

@ricardoogliari
Created July 7, 2019 03:35
Show Gist options
  • Save ricardoogliari/dfdc30ebef100ee2b38b1f6d9f2a4dc5 to your computer and use it in GitHub Desktop.
Save ricardoogliari/dfdc30ebef100ee2b38b1f6d9f2a4dc5 to your computer and use it in GitHub Desktop.
onMessage.dart
void _onMessage(List<mqtt.MqttReceivedMessage> event) {
final mqtt.MqttPublishMessage recMess =
event[0].payload as mqtt.MqttPublishMessage;
final String message =
mqtt.MqttPublishPayload.bytesToStringAsString(recMess.payload.message);
setState(() {
_temp = double.parse(message);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment