bluetooth (1.4.0)

Published 2026-09-22 14:19:46 +00:00 by Platform

Installation

dart pub add bluetooth:1.4.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
Pub
2026-09-22 14:19:46 +00:00
7
14 KiB
Assets (1)
1.4.0.tar.gz 14 KiB
Versions (10) View all
1.6.0 2026-10-01
1.5.0 2026-10-01
1.4.1 2026-09-22
1.4.0 2026-09-22
1.3.0 2026-09-22