Code Monkey home page Code Monkey logo

flutter_mqtt's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

flutter_mqtt's Issues

App Disconect

Hello, im trying you app, but when i try to connect in a second mobile, the first automatically disconnect, can you tell me what is wrong?

Rabbitmq

how can we connect rabbitmq with this package?

Requesting Guidance: Why is this project not using streams?

Hi,
I'm working on a similar MQTT based flutter project and I had to use streams for rebuilding my widgets upon message arrival. Why is it not essential here?

My Stream is not working tho, I'm using a stream controller to sink payload right after the the variable 'pt' is created and assigned a value. I'm listening to it with StreamBuilder Widget on main.dart and rebuilding a card based on it.

The issue is: the card does not rebuild upon message arrival. I can see the message print on the console(using Print) but the listener/subsriber doesn't seem to be working well.

Code:

class PayloadGiver {
  final mqttStream = StreamController<String>();

  void payloadGiver(String subscribeTopic) {
    if (mqttInitComplete == true) {
      print('Subscribing to $subscribeTopic');
      // Not a wildcard topic
//    client.subscribe(subscribeTopic2, MqttQos.atMostOnce);
      client.subscribe(subscribeTopic, MqttQos.atMostOnce);
      client.updates.listen((List<MqttReceivedMessage<MqttMessage>> c) {
        final MqttPublishMessage recMess = c[0].payload;
        final pt =
            MqttPublishPayload.bytesToStringAsString(recMess.payload.message);

        print('The payload is : $pt');

        mqttStream.sink.add(pt);
      });
    }
  }

Listener:

StreamBuilder<String>(
                      stream: mqttStream,
                      builder: (context, snapshot) {
//                        if (!snapshot.hasData) return Text('No Data');
//                        if (snapshot.connectionState == ConnectionState.waiting)
//                          print("Still Waiting for Data");
//                        print('Currently, I have: ' + snapshot.data);
                        if (snapshot.data == 'true')
                          return SwitchCardOn();
                        else if (snapshot.data == 'false') {
                          print(
                              "I recieved false but did not build the widget");
                          return SwitchCardOff();
                        } else
                          return Text('Waiting');
                      }),

Please help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.