bluetooth (1.5.0)
Published 2026-10-01 06:46:20 +00:00 by Platform
Installation
dart pub add bluetooth:1.5.0 --hosted-url=About this package
Bluetooth Low Energy abstractions for Dart: the transport interface every app talks to, and a logging decorator. Backends live in their own packages.
Dart.Package.Bluetooth
Bluetooth Low Energy abstractions for Dart: the transport interface an app talks to, and a decorator that records what went through it.
Same shape as the C# side, where CSharp.Package.Bluetooth holds the abstractions and
.Native, .PluginBLE and .InTheHand hold the backends. Here there is one backend,
bluetooth_universal_ble,
because universal_ble already covers Android, iOS, macOS, Windows, Linux and Web.
This package is pure Dart and stays that way. A backend needs a plugin and therefore Flutter; putting one here would stop every non-Flutter package from depending on the interface.
Quick start
import 'package:bluetooth/bluetooth.dart';
import 'package:bluetooth_universal_ble/bluetooth_universal_ble.dart';
final BleTransport transport = LoggingBleTransport(UniversalBleTransport());
await for (final device in transport.scan(const Duration(seconds: 4))) {
print('found ${device.name} at ${device.rssi} dBm');
}
Everything else in an app takes a BleTransport. A test passes its own implementation; there is
nothing to mock at the plugin level.
What each piece is for
BleTransport |
The interface. Scan, connect, disconnect, subscribe, read, write, connection events. |
BleAdvertisement, BleConnectionEvent |
What a scan and a connection change report. |
LoggingBleTransport |
Wraps any transport and records calls, durations and failures through dajno_logging. Bluetooth failures are usually invisible; this is what makes them readable afterwards. |
Project structure
pubspec.yaml
Version.txt the version to publish
lib/
├── bluetooth.dart public API - exports
└── src/
├── ble_transport.dart the interface
└── logging_ble_transport.dart the logging decorator
test/
└── logging_ble_transport_test.dart
example/
└── example.dart
Details
Assets (1)
Versions (10)
View all
1.5.0.tar.gz
16 KiB