mqtt_helper 0.0.4 mqtt_helper: ^0.0.4 copied to clipboard
mqtt_helper is a Flutter package that simplifies MQTT integration, reducing boilerplate code and providing a convenient layer on top of mqtt_client.
This package was initially created for internal use only, but can be used by anyone
Features #
- Wrapper class covering everything for mqtt_client
- Provides listeners on events and other callbacks for mqtt_client
Getting started #
Add it to your pubspec.yaml
mqtt_helper: <latest-version>
Usage #
- Create one instance of the helper class
MqttHelper
var helper = MqttHelper();
- Initialize and Connect to the MqttClient with the helper
var config = MqttConfig(); // You'll need to pass your creds and configs inside MqttConfig
helper.initialize(config);
Additional Information #
- Use
onConnectionChange()
listener to listen to connection changes whether Mqtt is connected or not - Use
onEvent()
listener to listen to events that will come. - Use
subscribeTopic()
to subscribe to single topic. - Use
subscribeTopics()
to subscribe to multiple topics at once. - Use
unsubscribeTopic()
to unsubscribe to single topic. - Use
unsubscribeTopics()
to unsubscribe to multiple topics at once.