Closed LuLeRoemer closed 5 years ago
Yes, this looks like a Dart 2 problem, flutter users have been reporting this type of breakage in various parts of the client, it seems to change depending on the flutter version being used. When Google release Dart 2 into production I'll update and fix the client accordingly, until then there's not much I can do.
I added a workaround in my repo:
pubspec.yaml:
#mqtt_client: "^1.7.2"
mqtt_client:
git:
url: https://github.com/benbehringer/mqtt_client.git
subscribe as follows:
import 'package:observable/observable.dart' as observe;
import 'package:mqtt_client/mqtt_client.dart' as mqtt;
final observe.ChangeNotifier<observe.ChangeRecord> cn = client.subscribe(topic, mqtt.MqttQos.exactlyOnce).observable;
cn.changes.listen((List<observe.ChangeRecord> c) {
mqtt.MqttReceivedMessage myMessage = c[0] as mqtt.MqttReceivedMessage;
final mqtt.MqttPublishMessage recMess = myMessage.payload as mqtt.MqttPublishMessage;
final String pt =
mqtt.MqttPublishPayload.bytesToStringAsString(recMess.payload.message);
print("EXAMPLE::Change notification:: payload is <$pt> for topic <$topic>");
});
my config:
Flutter 0.5.6 • channel dev • https://github.com/flutter/flutter.git
Framework • revision 472bbccf75 (2 weeks ago) • 2018-06-26 17:01:46 -0700
Engine • revision 6fe748490d
Tools • Dart 2.0.0-dev.63.0.flutter-4c9689c1d2
thanks @benbehringer for sharing your fork. It helped me resume progress on my flutter project. Since this project is tagged as supporting flutter, it seems that this issue should reach a more concrete resolution. At a minimum, maybe the docs and example should be updated with some footnotes and links regarding the problems with dart 2, and by extension, flutter.
Ok looks as though Dart 2 has hit stable, im just finishing my hols at the mo Ill update the package late this week/early next and see where we are then
Dart 2.0 updates are now tracked on issue 24
I believe the latest client(3.2.1) and flutter are now OK together, can you verify this.
Believe this is now fixed.
Can we use Mqtt_client for chatting app which will run both on IOS and Android. Please suggest. Thanks a lot
I believe some users do use the client for stuff like this using flutter so you can run it on IOS or Android, some users use it as a general purpose pub/sub mechanism, you will of course need your own MQTT broker somewhere, the mqtt_client is as it says only a client.
I believe some users do use the client for stuff like this using flutter so you can run it on IOS or Android, some users use it as a general purpose pub/sub mechanism, you will of course need your own MQTT broker somewhere, the mqtt_client is as it says only a client.
Thanks.
Do you have any reference link / example for code which implement the mqtt_client for chat or pub/sub. Thanks in advance.
Unfortunately, I get the following error running the example code:
It seems, there is a problem regarding publish messages. I'm using flutter v0.5.1.