如何在 flutter 中将数据以 JSON 形式发送到 MQTT 代理
return RaisedButton(
color: Colors.green,
disabledColor: Colors.grey,
textColor: Colors.white,
disabledTextColor:Colors.black38 ,
child: Text("Break"),
onPressed: state == MQTTAppConnectionState.connectedSubscribed
? () {
setState(() {
value = 0;
action = jsonData;
});
publishMessage(action);
}
: null, //
);
}
I have multiple buttons in my app that passes different message to mqtt client
I want to pass different json data to mqtt client for each button
sample json data for single button
{ "电机":"BLDC电机", “ACC”:70, “F/R”:“前进”, "Break":"假", “关键”:“真实” 端
按下按钮时帮助我将单个 json 数据传递给 mqtt 客户
return RaisedButton(
color: Colors.green,
disabledColor: Colors.grey,
textColor: Colors.white,
disabledTextColor:Colors.black38 ,
child: Text("Break"),
onPressed: state == MQTTAppConnectionState.connectedSubscribed
? () {
setState(() {
value = 0;
action = jsonData;
});
publishMessage(action);
}
: null, //
);
}
I have multiple buttons in my app that passes different message to mqtt client
I want to pass different json data to mqtt client for each button
sample json data for single button
{
"Motor":"BLDC motor",
"Acc": 70,
"F/R": "Forward",
"Break":"False",
"Key":"True"
}
help me to pass single json data to mqtt client when the button is pressed
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在发布方法中传递值并进行更改,它将起作用
Pass the values in the publish method and make this changes there it will work