How to implement MQTT in Flutter, so that with one MQTT instance i can update other UIs?

Viewed 717

I have implemented Mqtt wrapper class following this blog which can maintain connection with mqtt broker. Mqtt Wrapper class has all the functionality related to mqtt: Connect, Disconnect, Subscribe, Publish and receiving messages.

I want to use this wrapper in every other widgets so that i can subscribe to the topic which are only required in that widget and receive messages on subscribed topics to display received data.

It can be implemented using observable class, but it will only notify on message receive. I won't be able to subscribe to new topics.

How do i implement this functionality in flutter.

BTW, I also want to run this in background

I have referred this links but not able to find proper solution

  1. Implementing MQTT in Flutter
  2. advice on mqtt messaging implementation
0 Answers
Related