$ show chipweinberger/flutter_blue_plus
This repository implements **flutter_blue_plus**, a Flutter plugin library for Bluetooth Low Energy (BLE) communication across Android, iOS, macOS, Linux, and Web platforms. It provides a unified Dart API to perform BLE scanning, connect to devices, discover GATT services/characteristics/descriptors, read/write data, subscribe to notifications, and manage bonding and MTU negotiation. The architecture follows Flutter's federated plugin pattern: a common platform interface package defines abstract contracts and serialization messages, while separate packages implement the native side using MethodChannel (Android Java, iOS/macOS Objective-C, Linux Dart/BlueZ, Web JS interop). The library is designed for production use, featuring per-device operation queues via a mutex factory, robust error handling, streaming state updates, and conveniences like automatic subscription cleanup on disconnect. It is commercially licensed, requiring a paid license for commercial use. The codebase is well-structured with clear separation of concerns, though it carries a moderate amount of deprecated API surface and some platform-specific workarounds. The example app demonstrates all major features and serves as both a test harness and reusable UI pattern for BLE exploration.
The LLM identified 3 files worth highlighting for reuse:
A reusable Mutex pattern that serializes asynchronous operations per resource (e.g., per BLE device). Uses a keyed factory to create per-resource mutexes, ensuring sequential execution of operations like read/write/connect. Self-contained, depends only on dart:async and dart:collection. Can be extracted and used in any Flutter/Dart project requiring ordered access to shared resources.
A collection of pure-stream utility functions and extensions (mergeStreams, startWith, switchMap, newStreamWithInitialValue) that solve common reactive problems in a null-safe, type-safe way. No internal dependencies beyond dart:async. These are generic and can be extracted as a standalone package for any Dart stream manipulation.
A robust, self-contained UUID class that parses 16/32/128-bit BLE UUIDs, normalizes to standard 128-bit format, and provides equality and string formatting. No dependencies beyond Dart core. This is a classic extractable utility for any project dealing with BLE or custom UUID validation.