mqtt_helper 0.1.0 copy "mqtt_helper: ^0.1.0" to clipboard
mqtt_helper: ^0.1.0 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.

A wrapper package for mqtt_client that provides a simpler and more intuitive API for working with MQTT in Flutter.

Features #

  • Wrapper class covering everything for mqtt_client
  • Provides listeners on events and other callbacks for mqtt_client
  • Simplifies the usage of mqtt_client with a wrapper class
    • Provides listeners for connection changes and events
    • Supports subscribing and unsubscribing to single or multiple topics
    • Allows publishing messages to MQTT topics

Getting started #

Add it to your pubspec.yaml

dependencies:
  mqtt_helper: <latest-version>

Usage #

  1. Create one instance of the helper class MqttHelper
var helper = MqttHelper();
  1. 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 #

Listeners #

  • Use onConnectionChange() listener to listen to connection changes whether Mqtt is connected or not
  • Use onEvent() listener to listen to events that will come.

Subscribing and Unsubscribing #

  • 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.
5
likes
140
pub points
58%
popularity

Publisher

unverified uploader

mqtt_helper is a Flutter package that simplifies MQTT integration, reducing boilerplate code and providing a convenient layer on top of mqtt_client.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_web_plugins, mqtt_client

More

Packages that depend on mqtt_helper