Search packages, repositories and app categories

Package detailsv10.14.0

mqtt_client

A server and browser based MQTT client for Dart supporting normal, secure sockets and websockets.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
117K
Likes
551
Pub points
160

Install package

flutter pub add mqtt_client

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

The mqtt_client package is a Dart implementation of an MQTT client that enables real-time communication between devices and servers. It supports standard, secure (TLS), and WebSocket connections, making it suitable for both server-side and browser-based applications. Designed for cross-platform use, it works seamlessly across Android, iOS, Web, macOS, Windows, and Linux. Ideal for IoT projects, it facilitates lightweight, publish-subscribe messaging with low latency and high efficiency.

Use cases

  • IoT device communication
  • Real-time data streaming
  • Remote sensor monitoring
  • Smart home automation
  • Live dashboard updates
  • Cloud-to-device messaging

Key features

  • Supports MQTT over TCP, TLS, and WebSockets
  • Cross-platform compatibility
  • Lightweight and efficient
  • Robust connection handling
  • Publish/subscribe messaging model
  • Automatic reconnection

Suitable for

  • IoT developers
  • Real-time application builders
  • Backend services requiring pub/sub
  • Web-based dashboards
  • Mobile apps needing live updates

Considerations

  • Requires proper broker setup
  • May need additional configuration for secure connections
  • Not ideal for high-frequency, low-latency scenarios without tuning
  • Dependent on external MQTT broker availability

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

mqtt_client

Build Status FOSSA Status

A server and browser based MQTT client for Dart.

The client is an MQTT v3(3.1 and 3.1.1) implementation(an equivalent MQTT v5 client can be found here) supporting subscription/publishing at all QOS levels, keep alive and synchronous connection. The client is designed to take as much MQTT protocol work off the user as possible, connection protocol is handled automatically as are the message exchanges needed to support the different QOS levels and the keep alive mechanism. This allows the user to concentrate on publishing/subscribing and not the details of MQTT itself.

Examples of usage can be found in the examples directory. An example is also provided showing how to use the client to connect to the mqtt-bridge of Google's IoT-Core suite. This demonstrates how to use secure connections and switch MQTT protocols. The test directory also contains standalone runnable scripts demonstrating subscription, publishing and topic filtering.

The server client supports both normal and secure TCP connections and secure(wss) and non-secure(ws) websocket connections. The browser client supports only secure(wss) and non-secure(ws) websocket connections.

The client has been used successfully with the MQTT brokers from several of the major cloud providers IOT/MQTT platforms, including :-

  • Google IOT Core
  • Amazon AWS
  • Microsoft Azure
  • IBM

It has also been used with a range of both publicly available brokers such as Mosquitto and proprietary ones. An example using the adafruit MQTT broker for flutter can be found here.

The code is originally a port from the C# nMQTT client library to Dart.

Please read the changelog for details related to specific versions.

Installation

If you are using the client in a flutter environment on Android or iOS devices then the following device permission settings are necessary.

iOS

Add the following keys to your Info.plist file, located in ios/Runner/Info.plist:

<key>NSLocalNetworkUsageDescription</key>
<string>Looking for local tcp Bonjour service</string>
<key>NSBonjourServices</key>
<array>
  <string>mqtt.tcp</string>
</array>
Android

Add the following Android permissions to the AndroidManifest.xml file, located in android/app/src/main/AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

License

FOSSA Status

Categories

Dependencies

Dependency list 7 items

Source repository

Projects using this package

Rankings