bluetooth_universal_ble (1.2.2)
Installation
dart pub add bluetooth_universal_ble:1.2.2 --hosted-url=About this package
Dart.Package.Bluetooth.UniversalBle
The universal_ble backend for
package:bluetooth.
package:bluetooth holds the interface and is pure Dart, so anything can depend on it. This
package holds the implementation and needs Flutter, because universal_ble is a plugin. Same
split as the C# side, where CSharp.Package.Bluetooth holds the abstractions and .Native,
.PluginBLE and .InTheHand hold the backends. There is one backend here rather than three,
because universal_ble already covers Android, iOS, macOS, Windows, Linux and Web.
Quick start
import 'package:bluetooth/bluetooth.dart';
import 'package:bluetooth_universal_ble/bluetooth_universal_ble.dart';
final BleTransport transport = LoggingBleTransport(UniversalBleTransport());
Two behaviours worth knowing
Notify, then indicate. Some characteristics only support indications, including the Fitness
Machine Control Point (0x2AD9) on every trainer worth naming; subscribeNotifications throws on
those. This transport tries notify, falls back to indications, and treats a characteristic that
refuses both as a sensor that will not report rather than as an error to crash on.
A write waits for its own subscription. subscribe returns its stream immediately while the
platform call is still in flight, so a command written straight after could reach the device
before the subscription carrying its reply existed. Writes wait on that device's pending
subscription first.
CI
Publishing needs the Flutter SDK, so the job runs in ghcr.io/cirruslabs/flutter:stable and
checks out with git rather than actions/checkout (that image carries no Node, which a
JavaScript action needs), then uses the shared
flutter-publish action.