BBManager class
The entry point for BlueBreeze: tracks Bluetooth authorization and power state, and discovers peripherals as BBDevice instances.
Create and retain a single BBManager for the lifetime of your app (or feature). All of
its state is exposed as Streams so your UI can observe it reactively:
final manager = BBManager();
manager.stateStream.listen((state) {
if (state == BBState.poweredOn) {
manager.scanStart();
}
});
manager.scanResultsStream.listen((result) {
print('${result.name ?? 'Unknown device'} ${result.rssi}');
});
Constructors
Properties
-
The app's current authorization status for the Bluetooth permissions BlueBreeze needs.
Call authorizationRequest to request them if this isn't BBAuthorization.authorized.
no setter
-
Notifies with the updated authorizationStatus every time it changes.
no setter
-
devices
→ Map<
String, BBDevice> -
Every BBDevice discovered by a scan so far, keyed by id. A device is added here the
first time it's seen in a scan result and then reused for every subsequent sighting,
connect, and disconnect -- use this (or BBScanResult.device) rather than constructing
your own.
no setter
-
devicesStream
→ Stream<
Map< String, BBDevice> > -
Notifies with the updated devices map every time a new device is discovered.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scanEnabled → bool
-
Whether a scan is currently active. Reflects scanStart/scanStop, and flips to
falseon its own if the adapter powers off or the system stops the scan for another reason.no setter -
scanEnabledStream
→ Stream<
bool> -
Notifies with the updated scanEnabled every time it changes.
no setter
-
scanResultsStream
→ Stream<
BBScanResult> -
Every advertisement seen while scanning, including repeats from the same peripheral.
Only delivered to listeners while they're actively listening -- there's no replay, unlike
devicesStream/stateStream.
no setter
- state → BBState
-
The Bluetooth adapter's current power state. Scanning and connecting require
BBState.poweredOn.
no setter
-
stateStream
→ Stream<
BBState> -
Notifies with the updated state every time it changes.
no setter
- supportsExtended → bool
-
Whether this device's Bluetooth adapter supports extended LE advertising (larger/longer
advertisements, secondary advertising channels).
no setter
Methods
- Opens the app's system settings screen -- the only way to recover once a permission has been permanently denied (BBAuthorization.denied), since the system will no longer show its own request dialog for it.
- Requests every permission BlueBreeze needs, updating authorizationStatus with the result.
-
handleHotReload(
) → void -
Disconnects every known device. Intended to be called from a Flutter
reassemble()hook so a hot reload doesn't leave native connections open with no Dart-side listener left to manage them. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
releaseDevice(
String id) → void -
Releases locally cached stream state for the device with this
id(services, connection status, MTU, characteristic data/notify state). Call this once you're done with a device you no longer expect to reconnect to, to bound memory use across long scanning sessions -- state is recreated automatically if the device is seen or connected to again. -
scanStart(
{List< String> ? services}) → Future<void> - Starts scanning for BLE advertisements, updating scanEnabled and delivering results on scanResultsStream. Returns immediately if already scanning.
-
scanStop(
) → Future< void> - Stops an active scan. Returns immediately if not currently scanning.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited