mqtt_client
10.14.0, released 4 weeks ago by darticulate.com
A Dart MQTT client supporting TCP, WebSocket, secure connections and all QoS levels.
What it does
It implements MQTT v3.1 and v3.1.1, handling connection, subscription, publishing and keep‑alive automatically. It works on Android, iOS, web, desktop and server platforms.
AI-written summary of version 10.14.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- Building IoT or chat apps that need MQTT communication
- Integrating with cloud MQTT brokers like Google IoT Core, AWS IoT, Azure IoT Hub
- Creating Flutter apps that require real‑time messaging over MQTT
Skip it when
- You only need HTTP or WebSocket APIs
- Your project already uses a different MQTT client that better fits your architecture
Strengths
- Supports TCP, secure TCP, WebSocket and secure WebSocket
- Handles all QoS levels and keep‑alive automatically
- Batch and multi‑unsubscriptions, making it efficient for many topics
- Cross‑platform support (Android, iOS, web, desktop, server)
Weaknesses
- No native support for MQTT v5 (requires separate package)
- Requires platform permissions for network access on mobile
- Documentation is concise but may need digging for advanced use
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 7
Add INTERNET and ACCESS_NETWORK_STATE permissions on Android; add NSLocalNetworkUsageDescription and NSBonjourServices on iOS. No build_runner needed.
import 'package:mqtt_client/mqtt_client.dart';
final client = MqttClient('broker.hivemq.com', 'testClient');
await client.connect();
client.subscribe('topic/test', MqttQos.atLeastOnce);
client.publishMessage('topic/test', MqttQos.atLeastOnce, 'Hello');Alternatives
Packages that do the same job and could replace mqtt_client.
- mqtt5_client
A server and browser based MQTT Version 5 client for Dart supporting TCP and WebSockets.
92Compare - dart_mcp
A Dart library for building Model Context Protocol (MCP) servers and clients.
87Compare - stream_chat
Low‑level Dart client for Stream Chat API
91Compare - centrifuge
Dart client for real‑time communication with Centrifuge/Centrifugo over WebSockets.
80Compare
Works with
Packages commonly used together with mqtt_client: ones it builds on, ones built on it, and its own family.
- cryptomqtt_client depends on itProvides SHA, MD5, and HMAC hashing functions for Dart.
- webmqtt_client depends on itLightweight bindings for browser APIs via JS interop
- typed_datamqtt_client depends on itUtility functions and classes for easier work with dart:typed_data lists.
- charactersmqtt_client depends on itUnicode and grapheme cluster aware string manipulation operations for Dart.
- event_busmqtt_client depends on itA lightweight event bus using Dart Streams for publish/subscribe communication
- amity_sdkBuilt on mqtt_clientClient SDK for Amity Social Cloud to add social features like feeds, groups, and profiles.